When I cloned a repo from GitLab to local, it along with source code it also pulled a file in the root folder caller .gitignore
.
There is also a folder called .git
which contains a directory in info
contains a file called exclude
.
Which one is the one that does the ignore (to me ignore and exclude mean the same)? Is it the ignore or exclude?
Asked
Active
Viewed 3,926 times
15
-
1Ignore what vs exclude what? Both files serve a purpose, but you are not being clear about what purpose you are looking for. – Mad Physicist Jul 10 '17 at 16:41
-
You should not touch whatever is in `.git`. `.gitignore` is something you are providing. The `.git` files are not supposed to be manually modified. – Eugene Sh. Jul 10 '17 at 16:46
-
1@MadPhysicist I think the question is very clear. newb7777 just want to know what the purpose is of the two different files. – klutt Jul 10 '17 at 16:50
-
1Possible duplicate of [When would you use .git/info/exclude instead of .gitignore to exclude files?](https://stackoverflow.com/questions/22906851/when-would-you-use-git-info-exclude-instead-of-gitignore-to-exclude-files) – sergej Jul 10 '17 at 16:53
-
@klutt. I suppose you are right. I should have voted to close as a dupe instead of unclear. – Mad Physicist Jul 10 '17 at 16:58
-
1@EugeneSh. - That advice is not applicable to the `info/exclude` file – Mark Adelsberger Jul 10 '17 at 17:40
2 Answers
28
They both contain "ignore rules" - filename patterns for which matching untracked files should be ignored.
The difference is that rules in .gitignore
are shared through the repo, whreas rules in info/exclude
are not. So if for some reason you need to locally ignore certain paths in a single clone, you would use info/exclude
; but if a path should be ignored in all clones, you would use .gitignore

Mark Adelsberger
- 42,148
- 4
- 35
- 52
-
2To be clear: the `info/exclude` file you got when you cloned the repo *is not* a copy of the corresponding file on the origin. It is newly-created by git as a place to put rules specific to the new clone. – Mark Adelsberger Jul 10 '17 at 17:41
-
Yes that is correct. The exclude is newly created when i clone the repo from remote repo. `.gitignore` is the one from GitLab. – newb7777 Jul 10 '17 at 20:44
-
1if you have both files in the local repo, `.gitignore` and `info/exclude` which one takes precedence? This situation may arise when you are cloning someone else repository to your local repository and have updated your `info/exclude` file with your exclude list. – newb7777 Jul 11 '17 at 06:49
-
2
-4
Although the question is not about which is better ".gitignore" or "info/exclude", one thing to note is "gitignore" is instantaneous than exclude. It takes effect immediately during stating process versus "gitignore" takes effect in the beginning when you clone a repository.

newb7777
- 517
- 5
- 22