Writing ·
Git Nugget - Ignoring Files
When you have files or directories you would prefer git not to track:
1. Create a .gitignore file
2. Add the name of the file or directory you want to ignore, one per line
3. If you don’t want git to track the .gitignore file, you’ll add a line to the .gitignore file referencing itself. It will no longer be tracked.
Ex:
git status output: you might see an untracked file or dir you don’t want to follow, such as bin/**
vim .gitignore add following line: bin/**
git status output: this time you’ll no longer see bin listed as untracked, but you will see .gitignore now until you either start tracking it (git add whateverfilename), or else include .gitignore on a line of the .gitignore file itself
vim .gitignore add the line .gitignore**
git status output: no pesky unnecessary untracked files!
References: Git for the lazy stackoverflow