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 from 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 your .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 the 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 the repo? Yes No No

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

This entry was posted in General by bkielbasa. Bookmark the permalink.