Skip to content

Instantly share code, notes, and snippets.

@TangChr
Last active July 20, 2019 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TangChr/c69b60101fe1b953ddf39ca8efef441a to your computer and use it in GitHub Desktop.
Save TangChr/c69b60101fe1b953ddf39ca8efef441a to your computer and use it in GitHub Desktop.
Git Aliases
[alias]
ec = config --global -e
br = branch
sa = !git add --all
ca = !git add --all && git commit -m
up = !git pull --rebase --prune $@ && git submodule update --init --recursive
lrb = !git remote -v
co = checkout
cob = checkout -b
crb = !git cob $1 && git push origin -u
cop = !git co -
st = status
save = !git add --all && git commit -m "---SAVEPOINT---"
undo = reset HEAD~1 --mixed
logs = !git log --decorate --graph --pretty=format:'%Cred%h%Creset %Cgreen(%cd)%C(yellow)%d%Creset %s - %C(bold blue)%an%Creset' --abbrev-commit
amend = !git sa && git commit --amend -m
diffu = !git diff --name-only --diff-filter=U
cut = clean -fdx
unstage = !git reset HEAD --
unstage-all = !git reset HEAD -- .
discard = !git add --all && git commit -qm '---DISCARD SAVEPOINT---' && git reset HEAD~1 --hard
cmb = "!f() { git branch --merged master | grep -v "master" | xargs -r git branch -d; }; f"
done = "!f() { git checkout master && git up && git cmb; }; f"
lrt = ls-remote --tags origin
squash = !git rebase -i HEAD~2
add-remote = !git remote add
remove-remote = !git remote remove
set-remote-url = !git remote set-url
keep = !git stash save STASH
clear-stash = !git stash apply && git stash clear
rename-local = "!f() { git branch $1 -m $2; }; f"
rebase-master = "!f() { git co master && git up && git cop && git rebase master; }; f"
ls-branches = "!git for-each-ref --sort='-authordate' --format='%(authordate)%09%(objectname:short)%09%(refname)' refs/heads | sed -e 's-refs/heads/--'"
la = "!git config -l | grep alias | cut -c 7-"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment