We are still actively working on the spam issue.

Workstation backup via git

From InstallGentoo Wiki
Jump to: navigation, search

create an empy bare git repo

git init --bare $HOME/.cfg

whith this Step you hace a repo inside your home directory ```$HOME/.cfg ```. Inside there are laying your git management files.

create an alias

alias config="git --git-dir=$HOME/.cfg/ --work-tree=$HOME"

execute this ONCE

config config --local status.showUntrackedFiles no

if you execute it more than once, all your Home Files would be marked always as untracked. If you execute config status.

Now you can use the command config as you would do with git.

config status / commit / pull / push ... merge, rebase, reset...

add files, commit and push:

config add .vim
config commit -m "My new VIM config"
config push

set an upstream URL to Github etc. and push it

git clone --bare https://...../dotfiles.git $HOME/.cfg

ksh aliases (should also work for bash)

 # config command
 alias config='git --git-dir=$HOME/.cfg/ --work-tree=$HOME'

 # I'm lazy, so just commit with some machine info
 function dotfiles_autoupdate {
     config add -u && \
     config commit -m "Update $(date +"%Y-%m-%d %H:%M") $(uname -s)/$(uname -m)" && \
     config push
 # please give me my dotfiles...
 function dotfiles_init {
     git --no-replace-objects clone --bare \
         [email protected]:dotfiles.git $HOME/.cfg
     config config --local status.showUntrackedFiles no
     config checkout -f


Do not commit passwords!!! This sounds logical but is sometimes not so simple. Many programs / config folder can possibly contain cached passwords (vim) and you should also consider to create sample files like .configfile.sample containing only "******************" instead the real password. But that's only one example.

learn to commit with: --rebase, stash

not up-to-date branch

sometimes you change something on a not up-to-date branch. Because of that he advises in general

config pull --rebase # instad with config pull

uncommitted changes in git repo:

config stash
config pull --rebase
config stash apply


git --git-dir=$HOME/.cfg/ --work-tree=$HOME commit -a -m "AutoUpdate-$(hostname)-$(date +%d-%m-%Y"-"%H:%M:%S)"
git --git-dir=$HOME/.cfg/ --work-tree=$HOME push sh master
git --git-dir=$HOME/.cfg/ --work-tree=$HOME push origin master

Now you could for example create a Cronjob and your Dotfiles get automaticially committed and pushed to your gitrepo.