Summary
A .gitignore
file is used to list files and folders that Git should ignore.
Details
A .gitignore
file is used to list files and folders that Git should ignore. If the files and folders listed in the .gitignore
file have not been tracked or committed, then Git will not alert you about them when using the git status
command.
If you have already committed the files and then add them to the .gitignore
file, Git will continue to track the files. Additional steps will need to be taken to stop Git from tracking the files in this case. Therefore, it’s best to set up your .gitignore
file early and add files and folders as necessary as your project continues to grow.
The files and folders that need to be added to a .gitignore
file vary depending on what type of project you’re working on. For a simple static site, you may not need a .gitignore
file at all and will commit all of your project files in your repo. More complex projects may require several files and folder paths to be added to the .gitignore
file.
Exercises
In your text editor, create a new file and then save it. In the dialog box that appears, name the file .gitignore
.
References
gitignore Documentation from the Git website