Use git to manage home directory

I think you're looking for dotfiles.


I would suggest not putting your $HOME directory under git version control. I did this, because I thought I was exceedingly clever and wanted my .dotfiles under version control. However, git is greedy and ravenous. I had to add tons of directories (or even *) to my $HOME/.gitignore. And do you have any git repositories elsewhere in your home directory? I did. But those git repositories will use your $HOME/.gitignore as your global .gitignore unless you set that elsewhere. So it's a real pain to try and add files in these sub-directory repositories.

Instead, put your important files in a separate directory. Say, ~/dotfiles. Now make that a git repository, and symlink all of your important .dotfiles to point at that new repository. Voila. Problem solved, albeit with some time invested in linking.


.gitignore

# Ignore everything
*

# But not these files...
!*.vimrc
!*.vim
!*.bashrc
!.gitignore

# etc...

My home directory is also on GitHub.


I would setup an alias for use only with your home repo this way you can use the alias in place of git command and you always know the context you are working in

# .bashrc
alias home='git --work-tree=$HOME --git-dir=$HOME/.home'

Issuing the comand

$ home init

will create a repo in .home folder in your $HOME and irrelevant of current directory you can work with your home repo with the alias 'home' in place of 'git'

This alongside a .gitignore should be all you need.

# .gitignore
*
# keep track
!.bashrc
!.gitignore

NB. DO NOT KEEP .ssh/keys in repo as it presents file permission and security issues.

Tags:

Git