您的位置:首页 > 其它

Gitignore

2013-04-18 00:00 148 查看
Fortunately GIT has a very easy solution for this, just run the following command on the file or path you want to ignore the changes of:

git update-index --assume-unchanged <file>

# built application files

*.apk

*.ap_

# files for the dex VM

*.dex

# Java class files

*.class

# generated files

bin/

gen/

# Local configuration file (sdk path, etc)

local.properties

# Eclipse project files

.classpath

.project

# Proguard folder generated by Eclipse

proguard/

# Intellij project files

*.iml

*.ipr

*.iws

.idea/
 https://github.com/github/gitignore/blob/master/Android.gitignore 
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 dogit 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 atouch .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 acore.excludesfilesoption in your config file. You can set up a.gitignorefile in your HOME directory that will affect all of your repositories by running this command:

git config --global core.excludesfile ~/.gitignore

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: