Skip to content

Instantly share code, notes, and snippets.

@czj
Created October 5, 2012 07:18
Show Gist options
  • Save czj/3838523 to your computer and use it in GitHub Desktop.
Save czj/3838523 to your computer and use it in GitHub Desktop.
GIT aliases
[alias]
a = add
b = branch
c = commit
co = checkout
cob = checkout -b
d = diff --word-diff
l = log --oneline --decorate
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %Cblue(%an)%Creset' --abbrev-commit --date=relative
phcs = push hcsgit
ph = push heroku
p = push origin
st = status -sb
who = shortlog -n -s --no-merges
undo = reset --soft HEAD^
mm = merge master
restore = checkout --
# Amend current changes to the previous commit
amend = commit --amend -C HEAD
# remove the local and remote references for a given feature branch
rmb = !sh -c 'git branch -D $1 && git push origin :$1' -
# remove remote branch references that no longer exist, cleanup unnecessary git files and clear out your stash
cleanup = !git remote prune origin && git gc --aggressive && git stash clear
# same but remove untracked files from the working tree (dangerous !)
zcleanup = !git remote prune origin && git gc --aggressive && git clean -dfx && git stash clear
# Checkout a branch, rebase and merge to master
# git rebase HEAD feature && git rebase HEAD @{-2}
edit-unmerged = "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; subl -w `f`"
add-unmerged = "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; git add `f`"
changes = diff --name-status -r
diffstat = diff --stat -r
to = !sh -c 'git p && git co $1 && git merge @{-1} && git p && git co @{-1}' -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment