git ignore file, Git增加忽略文件
2011-08-16 23:13
316 查看
最简单的方法在项目根目录与.git目录同一位置创建一个文件: .gitignore
touch .gitignore
vi .gitignore
:wq
注:如果要忽略的文件已被git管理,需要先移除,命令如下:
e.g.:
git rm -r --cached WebRoot/WEB-INF/classes/**/*
-r:递归
git commit
然后.gitignore中的忽略,起作用
以下参考//-------------------
from:
http://gitready.com/beginner/2009/01/19/ignoring-files.html
The easiest and simplest way is to create a
Here’s a basic
Of course, this could get a lot more complex. You can also add exceptions to ignore rules by starting the line with
Two things to keep in mind with ignoring files: First, if a file is already being tracked by Git, adding the file to
You can also open up
Your final option with ignoring folders is adding a per-user ignore by setting up a
Read up on the manpage if you’d like to learn more about how ignores work. As always, if you have other ignore-related tips let us know in the comments.
touch .gitignore
vi .gitignore
:wq
注:如果要忽略的文件已被git管理,需要先移除,命令如下:
e.g.:
git rm -r --cached WebRoot/WEB-INF/classes/**/*
-r:递归
git commit
然后.gitignore中的忽略,起作用
以下参考//-------------------
from:
http://gitready.com/beginner/2009/01/19/ignoring-files.html
The easiest and simplest way is to create a
.gitignorefile in your project’s root directory. The files you choose to ignore here take affect for all directories in your project, unless if they include their own
.gitignorefile. This is nice since you have one place to configure ignores unlike SVN’s svn:ignore which must be set on every folder. Also, the file itself can be versioned, which is definitely good.
Here’s a basic
.gitignore:
$ cat .gitignore # Can ignore specific files .DS_Store # Use wildcards as well *~ *.swp # Can also ignore all directories and files in a directory. tmp/**/*
Of course, this could get a lot more complex. You can also add exceptions to ignore rules by starting the line with
!. See an example of this at the GitHub guide on ignores.
Two things to keep in mind with ignoring files: First, if a file is already being tracked by Git, adding the file to
.gitignorewon’t stop Git from tracking it. You’ll need to do
git rm --cached <file>to keep the file in your tree and then ignore it. Secondly, empty directories do not get tracked by Git. If you want them to be tracked, they need to have something in them. Usually doing a
touch .gitignoreis enough to keep the folder tracked.
You can also open up
$GIT_DIR/info/exclude(
$GIT_DIRis usually your
.gitfolder) and edit that file for project-only ignores. The problem with this is that those changes aren’t checked in, so use this only if you have some personal files that don’t need to be shared with others on the same project.
Your final option with ignoring folders is adding a per-user ignore by setting up a
core.excludesfilesoption in your config file. You can set up a
.gitignorefile in yourHOME directory that will affect all of your repositories by running this command:
git config --global core.excludesfile ~/.gitignore
Read up on the manpage if you’d like to learn more about how ignores work. As always, if you have other ignore-related tips let us know in the comments.
相关文章推荐
- git ignore file, Git增加忽略文件
- git ignore file, Git增加忽略文件
- Git忽略文件(ignore file)
- Github使用gitignore忽略增加指定文件
- Git之忽略文件(ignore file)
- Git之忽略文件(ignore file)
- Github使用gitignore忽略增加指定文件
- .gitignore 忽略文件 (忽略pods文件)需要进入podfile文件所在目录执行 pod install
- Github使用gitignore忽略增加指定文件
- Git之忽略文件(ignore file)
- Github使用gitignore忽略增加指定文件
- Github使用gitignore忽略增加指定文件
- Git之忽略文件(ignore file)
- GitHub之.gitignore使用1---Github使用gitignore忽略增加指定文件
- Github使用gitignore忽略增加指定文件
- Git之忽略文件(ignore file)
- Github使用gitignore忽略增加指定文件
- Git之忽略文件(ignore file)
- Github使用gitignore忽略增加指定文件
- Github使用gitignore忽略增加指定文件