Gitignore

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

你可能感兴趣的:(Gitignore)