.gitignore
file is a special hidden file very important working on a repository where you are developing a software. It tell to Git what files to ignore from tracking changes.
For example, a lot of IDE create folders with temporary or configuration files which is convenient to ignore during tracking operations to keep clean the interface.
Create a new file and call it .gitignore
. Then, to ensure that it has effect, add it to the staging area, then commit.
To modify this file you can use whatever text editor you want. If you use VS Code and you don't want to leave the command-line, you can run this command:
code .gitignore
Warning
If you add to the .gitignore
one or more files that you already added to the staging area, Git keeps to track them. To stop it tracking them, you need to remove these files from the staging area.
In Basics - Remove a file is explained how to do that.
The format of .gitignore
is completely arbitrary according with your needs, but exist a lot of templates that you can use as .gitignore
for your project. In fact, it is common that a project share some characteristics with others. For example, if you are working with Visual Studio, you can download from this GitHub repository a template from Visual Studio's project.
After have been downloaded the desired file, copy the content, then past it into your .gitignore
file.