git

git is everyone's favorite version control system.

How does it work?

Global .gitignore

There is nothing that annoys me more than cloning a bunch of .vscode, .atom, .idea and other directories alongside an interesting project. To keep your personal preferences from infiltrating everyone else's systems, you should use a global .gitignore file, which I like to place in my $HOME as .gitignore_global (but if you have a Linux system you should probably put it in your ~/.config directory).

Run the following command to introduce ~/.gitignore_global to Git:

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

Then you can use the familiar .gitignore syntax to ignore commonly ignored files:

.vscode
tags*
.DS_Store

Public and private configuration

If you share your dotfiles on the World Wide Web, or you just keep them in a git repo as a backup, you should probably not include your name, email and other things in your main git config, just so that others who might want to use it don't accidentally commit as you. Thankfully, Git lets us include configs into one another using the include directive:

.gitconfig
[include]
    path = ~/.gitconfig.local

Now you can add .gitconfig.local to your .gitignore in your dotfiles repository and publish the rest of the thing, while adding private config to the local one:

.gitconfig.local
[user]
	name = Ivan Oštrić
	email = [email protected]
	signingkey = 314838F5043A5EFF

Last updated

Was this helpful?