63

After reading proper section of GitHub Help I got completely lost. It says:

This file can be committed into the repository, thus sharing the rule list with any other users that clone the repository.

Up until now, people I've been talking to about Git were telling me that ".gitingore file must be committed or else its rules won't work!"

Every Git begginer's question: "Why .gitignore rules are not applied?" Could be answered with a simple: "Did you commit it?".

And now, here comes the GitHub Help saying, that this file can be commited, but it isn't necessary

2
  • 3
    Note that ignores that you don't want to share, e.g. specific configuration files for an IDE that only you use, can be ignored using .git/info/exclude. The format of this file is the same as .gitignore, but this file will never be committed.
    – Chris
    Feb 6, 2014 at 13:08
  • 2
    Also, the contents of .gitignore take effect as soon as the file is created or modified. The "committed" question usually refers to other files. E.g., if you commit file foo.c and then add foo.c to .gitignore, it will not get ignored. Your ignores prevent files from being tracked initially, but once they become tracked the ignore file does nothing to them.
    – Chris
    Feb 6, 2014 at 13:12

1 Answer 1

77

Yes, you can track the .gitignore file, but you do not have to.

The main reason of having this file into repository is to have everyone working on the project, ignoring same files and folders.

Also see this: Should you commit .gitignore into the Git repos?

2
  • 4
    So my question is (again) a duplicate! :| Funny thing, that I found nothing similar, though (I think) I was searching quite deeply. Anyway, thank you for your contribution!
    – trejder
    Feb 6, 2014 at 11:16
  • 14
    Well you were the top hit in the search results for me now so it seems you have gotten the SEO right. May 2, 2019 at 23:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.