How to manage your dotfiles with git

Based on a Hacker News solution proposed by StreakyCobra

In his own words, some advantages of this approach are:

No extra tooling, no symlinks, files are tracked on a version control system, you can use different branches for different computers, you can replicate you configuration easily on new installation.

Getting started

If you're starting from scratch, go ahead and…

  • create a .dotfiles folder, which we'll use to track your dotfiles
  • create an alias dotfilesso you don't need to type it all over again
  • set git status to hide untracked files
  • add the alias to .bashrc (or .zshrc) so you can use it later


Now you can use regular git commands such as:

Nice, right? Now if you're moving to a virgin system…

Setup environment in a new computer

Make sure to have git installed, then:

  • clone your github repository
  • define the alias in the current shell scope
  • checkout the actual content from the git repository to your $HOME

Note that if you already have some of the files you'll get an error message. You can either (1) delete them or (2) back them up somewhere else. It's up to you.

Awesome! You’re done.

Are you into productivity hot tips for web development? I’m a Brazilian full-stack developer, living and working in Paris, and I regularly share articles like the one you’ve just read. Follow me on twitter to stay tuned.

Brazilian full-stack developer. Living and working in Paris. Sharing productivity hot tips for web development.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store