How to create a global .gitignore file
and forget to ignore the same files over and over again! ⚡️
Sometimes while we are creating a pull request, we realise we are committing some unnecessary config files, like the settings from your IDE, some cache files or even auto-generated files like the
Fortunately, there is a way to ignore all these files in your system and don’t bother to add them anymore to every project in the specific
The first step is to create the global
.gitignore file we are going to use.
Depending on your SO, the IDE, the programming language, etc that you use, the content of this file could vary, but the idea is to place it here all these files you want to omit.
Finally, let’s add this file to your
git as follows:
git config --global core.excludesFile ~/.gitignore
You can confirm your file was added by running the previous command without specifying the path.
You should see the file location, if so, it should be done 🐙
git config --global core.excludesFile
/Users/Jesus/.gitignore # Output 👀
If you are not working alone on a project, consider that maybe other people are not ignoring the duplicate files globally as you do, so for this, it is worth adding these lines not only on your global but in the
.gitignorefrom that project.
Happy programming! 🤓