Skip to content

Instantly share code, notes, and snippets.

@Shtian
Last active February 12, 2024 14:40
Show Gist options
  • Save Shtian/1b31cbd1bdc38f6532e2 to your computer and use it in GitHub Desktop.
Save Shtian/1b31cbd1bdc38f6532e2 to your computer and use it in GitHub Desktop.
Git aliases
[rerere]
enabled = true # reuse recorded resolution of conflicted merges
autoUpdate = true # update the index with reused conflict resolution if possible
[column]
ui = auto # show branch list in columns
[branch]
sort = -committerdate # sort branches by committer date
[alias]
co = checkout
c = commit -m
ai = add -p # add interactive
ec = config --global -e # open global config
up = !git pull --rebase --prune $@ && git submodule update --init --recursive # get all changes including submodules
cob = checkout -b
cm = !git add -A && git commit -m
st = status
pub = "!f() { git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD); }; f" # publish current branch to origin
save = !git add -A && git commit -m 'SAVEPOINT'
undo = reset HEAD~1 --mixed
amend = commit -a --amend
wipe = !git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard
bclean = "!f() { git branch --merged ${1-master} | grep -v ${1-master}$ | xargs -r git branch -d; }; f" # delete merged branches
bdone = "!f() { git checkout ${1-master} && git up && git bclean ${1-master}; }; f"
lg = log --color --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
mm = !git checkout master && git up && git co - && git merge master
rema = !git checkout master && git up && git co - && git rebase master
purge = "!f(){ git branch -vv | grep ': gone]' | gawk '{print $1}' | xargs git branch -D; }; f" # Remove branches with a deleted remote
which = "!f(){ git branch -a | grep -i $1 -m1 | sed 's/remotes\\/origin\\///'; }; f"
col = "!f() { git checkout $(git which $1); }; f" # "checkout lucky" checkout first matching branch
pushf = push --force-with-lease
staash = stash --all
diffw = diff --word-diff
blamef = blame -w -C -C -C # ignore whitespace and file movement/renames
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment