As you remember, Gert, on The X-Files, you explicitly ask it to, but it could happen that you ask
it to track some files by mistake.
For instance, you could issue the command grid at DOT, and as you remember, this command will add
all the files in the repository to be tracked.
We have a way to hide certain files from Git that you know you'll never want it to track.
To do this, we have to add it dot git ignore file.
This configuration file is added to the root directory of the repository and it lists files you don't
want git to track or display as part of git status.
You can add items to the dot git ignore file and commit them.
By the way, all the file is listed in git ignore is not meant to be tracked.
It's possible that you could accidental lee tell git to track a file that's listed in there.
If that happens, you won't get any error message.
This is another reason you should avoid running git at DOD as it may cause files to be tracked by git
unintentionally.
Examples of files that you might want to add to get ignored include such files as dot xy or some dot
db on windows.
Or you could exclude the whole directory the whole repository by adding the directory to this file.
Now let me create a directory called temp and create a file called config.
TXT.
I want git to ignore this directory, this repository and this file so I'll open the dot git ignore
file with nano editor and I'll type temp slash and config txt.
I'll press control x and save the settings and let's try run and get status command now.
And as you can see, these files are not tracked.
The output gives us only the dot git ignore file, although it's advised to add the dot git ignore file
to your repository.
You can even hide the dot git ignore file from git.
Just add a line dot git ignore to the file and get will ignore this file as well.
However, in such a situation the file will only reside in the local copy of the repository.
So that's for you to decide.
You can find many git ignore templates online depending on the framework you are working on, such as
rails.
For example, you may want to browse through this huge collection of dot git ignore files on GitHub.
This templates serve as handy starting points for new projects.
Please keep in mind that you should set up your dot git ignore early because if you add dot git ignore
file at the late stage of a project and then add some file to it which is already committed, it will
still continue to be committed in your repository and tracked by Git.
The only way out in this case is to explicitly track the file in git, after which git will ignore the
file.