Git Tips #2 Gitignore

Tips on Git: Gitignore

For those who don't use it yet, the gitignore file allows you to specify to git a list of files to ignore. That is to say that they will be hidden in the list of untracked files, and that git will not take their modifications into account. This way, less risk of mistakenly adding a local configuration file or a binary that will pollute the repository, while keeping a clear git interface.

You can put files and folders directly into gitignore, and use wildcards to get something more generic. You can even use the symbol ! to say that we want all files that do not match to to a defined pattern. Here are some examples of what can be fed to the file .gitignore :

.project **/logs **/logs/debug.log *.log !important.log *.log !important/*.log trace.* debug?.log debug[0-9].log debug[01]. log debug[!01].log

Create this file at the start of any git-managed project, at the earliest to avoid polluting the repository with files that don't belong there.

To facilitate the creation of this configuration, the site Gitignore.io allows you to choose a list of keywords and generate the .gitignore matching!

screenshot website Gitignore.io

Warning ! Do not forget to commit this file so that it becomes an integral part of the project, and that all developers can benefit from it 😉

Marine

Check all
Career area
Subscribe to the newsletter :
These articles may interest you