Managing your home's dot files as git repo an approach well documented by @durdn.
git init --bare $HOME/.cfg
alias cfg='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
cfg config --local status.showUntrackedFiles no
echo ".cfg" >> .gitignore
cfg add .gitignore
echo "alias cfg='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'" >> $HOME/.bashrc
cfg status
cfg add .vimrc
cfg commit -m "Add vimrc"
cfg add .bashrc
cfg commit -m "Add bashrc"
cfg push
The key alias:
alias cfg='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
git clone --bare [email protected]:dayne/dots.git $HOME/.cfg
alias cfg='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
cfg config --local status.showUntrackedFiles no
cfg checkout
# fix/move any conflicting files .. mv CONFLICT CONFLICT_backup
# repeat the cfg checkout as needed
git clone --bare https://bitbucket.org/durdn/cfg.git $HOME/.cfg
function cfg {
/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME $@
}
mkdir -p .config-backup
cfg checkout
if [ $? = 0 ]; then
echo "Checked out config.";
else
echo "Backing up pre-existing dot files.";
cfg checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | xargs -I{} mv {} .config-backup/{}
fi;
cfg checkout
cfg config status.showUntrackedFiles no