Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
2 views
in DevOps and Agile by (19.7k points)

I just created a Github repository and was wondering what the .gitignore file was for. I started by not creating one, but added one due to the fact that most repositories have one. Do I need to have one? Can/do I just ignore it, or does it have a use? I did some research on the subject but couldn't find a concrete explanation.

1 Answer

+1 vote
by (62.9k points)

A gitignore file specifies by choice untracked files that git should ignore.

Files already tracked by git don't seem to be affected; see the NOTES below for details.

Each line in a gitignore file identifies a pattern.

When deciding whether or not to ignore a path, git continually detects for gitignore patterns from multiple sources, with the subsequent order of precedence, from highest to lowest (within one level of precedence, the last matching pattern decides the outcome):

  • Patterns browse from the command line for those commands that support them.

  • Patterns read from a .gitignore file in a similar directory as the path, or in any parent directory, with patterns within the higher level files (up to the highest level of the work tree) being overridden by those files in the lower level down to the directory containing the file.

  • These patterns match relative to the path of the .gitignore file.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...