Almost everyone heard about and used GIT. It is a good idea to know better tools we use so I found 3 ways to ignore file/folder you may not know. Interested?

.gitignore file

This is the most popular way to remove some items for your repository. Just add the .gitignore file to your project and it just works. You need to remember that if you add the file to ignoring list it will be applied to every collaborator.

Global .gitignore file

If you want to exclude items from your repository but you do not want it should affect others work, you should use global .gitignore file. You need to create a file outside your repository (generally in your home folder) and tell GIT he should read ignored file list from the file. For example, we created the file and called it ~/.gitignore_global.

git config --global core.excludesfile ~/.gitignore_global

The –global parameter tells GIT we want to affect it to every repository.

Very secret .git/info/exclude file

Not everyone knows that there is a file in you .git folder where you can put your unwanted files. And yes – the file is .git/info/exclude. It will work generally like .gitignore but it will affect only this single repository and will not be sent to remote repository.

I think it can be a bit confusing. That’s why I created a simple table with a quick overview.

.gitignore Globa .gitignore Secret .git/info/exclude file
Range Single repository All repositories Single repository
Saved in repo? Yes No No

Now you have more mystic knowledge about GIT. I hope you will find it useful.

About the author

Bartłomiej Kiełbasa

Bartłomiej Kiełbasa

Hi! I'm Bartek. I'm a PHP developer but other languages are not scary to me. My hobby is security and I try to learn as much as it's possible how to not be hacked. I'd ike to know how things work. After hours I like playing Dota2 and watching Dragon Ball :) If you will have any question, feel free to ask.