Is there an ignore command for git like there is for svn?
There is no special git ignore
command.
Edit a .gitignore
file located in the appropriate place within the working copy. You should then add this .gitignore
and commit it. Everyone who clones that repo will than have those files ignored.
Note that only file names starting with /
will be relative to the directory .gitignore
resides in. Everything else will match files in whatever subdirectory.
You can also edit .git/info/exclude
to ignore specific files just in that one working copy. The .git/info/exclude
file will not be committed, and will thus only apply locally in this one working copy.
You can also set up a global file with patterns to ignore with git config --global core.excludesfile
. This will locally apply to all git working copies on the same user's account.
Run git help gitignore
and read the text for the details.
On Linux/Unix, you can append files to the .gitignore file with the echo
command. For example if you want to ignore all .svn
folders, run this from the root of the project:
echo .svn/ >> .gitignore
A very useful git ignore command comes with the awesome tj/git-extras.
Here are a few usage examples:
List all currently ignored patterns
git ignore
Add a pattern
git ignore "*.log"
Add one of the templates from gitignore.io
git ignore-io -a rails
git-extras provides many more useful commands. Definitely worth trying out.