Git Cheat Sheet
Many of these came from help.github.com. I’ll probably edit this post as I learn more about git.
Several ways I can figure out to see my settings are:
cat .git/config #Project Settings cat ~/.gitconfig #Global Settings git config --list |
Some of my default setups are as follows:
git config --global user.name "Michael Tuttle" git config --global user.email "username@mstuttle.com" git config --global color.ui true |
Defaults run in individual repos:
git config core.filemode false |
Some of the aliases that I use are:
git config --global alias.amend 'commit --amend' git config --global alias.backup '!git checkout -b backup-$(date +"%Y-%m-%d_%H-%M-%S")-$(git symbolic-ref --short HEAD); git checkout -; git lg -4' git config --global alias.br branch git config --global alias.ck checkout git config --global alias.ckb 'checkout -b' git config --global alias.cm commit git config --global alias.cmm 'commit -m' git config --global alias.date '!git commit --amend --no-verify --no-edit --date="$(date)"' git config --global alias.ds 'diff --staged -C' git config --global alias.fa 'fetch --all' git config --global alias.fu 'fetch upstream' git config --global alias.prune-all '!git remote | xargs -n 1 git remote prune $1' git config --global alias.st status git config --global alias.standup '!git lg --since yesterday --author "$(git config user.name)" --all' git config --global alias.undo 'reset --soft HEAD^' |
One thing that I was finally able to find on the web was setting the tab widths to 4 instead of 8.
git config --global core.pager 'less -FXRS -x4' |
Update: I just ran into an interesting alias from junkie.net. It creates a nice little git log view for the command line.
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative" git config --global alias.la '!git lg --all' git config --global alias.l '!git lg -10' |