Skip to content

Instantly share code, notes, and snippets.

@johnor
Created August 10, 2020 23:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnor/ac1c69003bdcc1a2d63cffbd471f90f2 to your computer and use it in GitHub Desktop.
Save johnor/ac1c69003bdcc1a2d63cffbd471f90f2 to your computer and use it in GitHub Desktop.
[alias]
br = branch -vv
brr = branch -r -vv
ci = commit
co = checkout
cp = cherry-pick
d = diff
dm = diff --submodule=log
ds = diff --staged
dsm = diff --staged --submodule=log
dt = difftool
mg = merge
mt = mergetool
rb = rebase
sh = show
shm = show --submodule=log
sm = submodule
st = status
rbi = !sh -c \"git rebase -i `git merge-base $1 HEAD`\" -
rb-smart = rebase -s recursive -Xpatience -Xignore-space-change -Xfind-renames -Xrename-threshold=40%
merge-smart = merge -Xignore-space-change -Xfind-renames -Xrename-threshold=40%
cp-smart = cherry-pick -Xignore-space-change -Xfind-renames -Xrename-threshold=40%
amend = commit -a --amend --no-edit
la = "!git config -l | grep alias | cut -c 7-" # list all aliases
ll = log --graph --abbrev-commit --branches --remotes --pretty=format:'%C(yellow)%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(blue)[%an]%Creset'
lb = log --graph --abbrev-commit --date=relative --pretty=format:'%C(yellow)%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(blue)[%an]%Creset'
l = log --graph --abbrev-commit --branches --pretty=format:'%C(yellow)%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(blue)[%an]%Creset'
lf = log --decorate --stat --pretty=format:'%C(yellow)%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(blue)[%an]%Creset'
wip = log --graph --pretty=format:'%C(yellow)%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(blue)[%an]%Creset' --decorate --all --ancestry-path HEAD~5..
w = "!f() { git wip; }; f"
wipa = log --all --graph --abbrev-commit --simplify-by-decoration --pretty=format:'%C(yellow)%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(blue)[%an]%Creset'
wipo= log "@{upstream}~1.." --oneline # @{u} means upstream branch of current branch
# https://dpwright.com/posts/2015/01/27/updating-git-branches-youre-not-on
# Usage: git sync master
remote-for-branch = "!f() { git for-each-ref --format='%(upstream:short)' `for b in $@; do echo refs/heads/$b; done` | sed 's:/.*$::'; }; f"
sync = "!f() { for b in $@; do git fetch `git remote-for-branch $b` $b:$b; done }; f"
# https://gist.github.com/robmiller/6018582
delete-merged-branches = "!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"
mergetest = "!f(){ git merge --no-commit --no-ff \"$1\"; git merge --abort; echo \"Merge aborted\"; };f "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment