Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I commit .gitignore file? [duplicate]

Tags:

git

github

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

like image 836
trejder Avatar asked Feb 06 '14 10:02

trejder


People also ask

Should Gitignore files be committed?

gitignore file must be edited and committed by hand when you have new files that you wish to ignore. . gitignore files contain patterns that are matched against file names in your repository to determine whether or not they should be ignored.

Are Gitignore files cloned?

gitignore file. If a file is added, committed and another commit with the . gitignore is created, the file will still be part of the repository and therefore cloned.

Should I have multiple Gitignore files?

A . gitignore file is a plain text file where each line contains a pattern for files/directories to ignore. Generally, this is placed in the root folder of the repository, and that's what I recommend. However, you can put it in any folder in the repository and you can also have multiple .

Should I push Gitignore file?

A . gitignore file lists all of the files that are local to a project that Git should not push to GitHub. A . gitignore always goes in the top level of the project directory, which is also called the project's 'root'.


1 Answers

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?

like image 183
e h Avatar answered Oct 03 '22 07:10

e h