GIT的 .gitignore 配置

.gitignore 配置文件用于配置不需要加入版本管理的文件,配置好该文件可以为我们的版本管理带来很大的便利,以下是个人对于配置 .gitignore 的一些心得。

1、配置语法:

  以斜杠“/”开头表示目录;

  以星号“*”通配多个字符;

  以问号“?”通配单个字符

  以方括号“[]”包含单个字符的匹配列表;

  以叹号“!”表示不忽略(跟踪)匹配到的文件或目录;

  

  此外,git 对于 .ignore 配置文件是按行从上到下进行规则匹配的,意味着如果前面的规则匹配的范围更大,则后面的规则将不会生效;

2、示例:

  (1)规则:fd1/*
      说明:忽略目录 fd1 下的全部内容;注意,不管是根目录下的 /fd1/ 目录,还是某个子目录 /child/fd1/ 目录,都会被忽略;

  (2)规则:/fd1/*
      说明:忽略根目录下的 /fd1/ 目录的全部内容;

  (3)规则:

/*
!.gitignore
!/fw/bin/
!/fw/sf/

说明:忽略全部内容,但是不忽略 .gitignore 文件、根目录下的 /fw/bin/ 和 /fw/sf/ 目录;

团队开发的时候,由于多人修改项目文件,有些文件是不需要提交的
 
这个时候写在.gitignore里面就行了,否则会出现问题的
 
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
#
# Pods/
 
把这些内容复制出来,存在.gitignore里面,然后丢在项目根目录就行了
 
这个文件是隐藏的

http://www.cnblogs.com/sinojelly/archive/2011/08/07/2130172.html

原文地址:https://www.cnblogs.com/likuiliang/p/3992471.html