Use git to manage home directory
I'd like to create one single git repo in my Linux $HOME directory. In this repo - obviously - I could add everything under version control, but this wouldn't make any sense. I'd like to only add the files and folders that are relevant to me, like .vimrc, .vim, .bashrc, etc. (probably only hidden files and folders, but maybe not)
I know I could leverage .gitignore to try and achieve such behavior but that would be painful and virtually un-maintainable. Instead, what I'd want to know is if there'd be any way to manually declare files and folders that I would want to manage, and only that.
Solution 1:
.gitignore
# Ignore everything
*
# But not these files...
!*.vimrc
!*.vim
!*.bashrc
!.gitignore
# etc...
My home directory is also on GitHub.
Solution 2:
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.