How can I stop .gitignore from appearing in the list of untracked files?

You could actually put a line .gitignore into your .gitignore file. This would cause the .gitignore file to be ignored by git. I do not actually think this is a good idea. I think the ignore file should be version controlled and tracked. I'm just putting this out there for completeness.


If you want to store the list of ignored files outside of your Git tree, you can use the .git/info/exclude file. It is applied only to your checkout of the repo.


You can also have a global user git .gitignore file that will apply automatically to all your repos. This is useful for IDE and editor files (e.g. swp and *~ files for Vim). Change directory locations to suit your OS.

  1. Add to your ~/.gitconfig file:

    [core]
    excludesfile = /home/username/.gitignore
    
  2. Create a ~/.gitignore file with file patterns to be ignored.

  3. Save your dot files in another repo so you have a backup (optional).

Any time you copy, init or clone a repo, your global gitignore file will be used as well.


The .gitignore file should be in your repository, so it should indeed be added and committed in, as git status suggests. It has to be a part of the repository tree, so that changes to it can be merged and so on.

So, add it to your repository, it should not be gitignored.

If you really want you can add .gitignore to the .gitignore file if you don't want it to be committed. However, in that case it's probably better to add the ignores to .git/info/exclude, a special checkout-local file that works just like .gitignore but does not show up in "git status" since it's in the .git folder.

See also https://help.github.com/articles/ignoring-files