Skip to content

Instantly share code, notes, and snippets.

@pixelbrackets
Last active May 22, 2019 09:43
Show Gist options
  • Save pixelbrackets/4477369 to your computer and use it in GitHub Desktop.
Save pixelbrackets/4477369 to your computer and use it in GitHub Desktop.
Git Aliases
[alias]
# Status
st = status
sti = status
s = status
tst = status
ts = status
str = status
stt = status
# Branch
br = branch
bre = branch
tbr = branch
b = branch
branches = branch
remotebranches = branch -a
mergedbranches = branch -a --merged
hascommit = branch -a --contains
removebranch = !sh -c 'git branch -D $1 && git push origin :$1' -
cleanbranches = "!f() { git branch --merged ${1-master} | grep -v " ${1-master}$" | xargs -r git branch -d; }; f"
### this alias may be replaced with simply »git cherry master -v«
showcommitdifference = "!f() { git log --left-right --graph --cherry-pick --oneline ...${1-master}; }; f"
# Add
a = add -p
addpartial = add -p
unstage = reset HEAD --
unadd = reset HEAD --
clearstage = reset HEAD
# Commit
ci = commit -v
tcommit = commit
comimt = commit
uncommit = reset --soft HEAD~1
amend = commit --amend
ammend = commit --amend
amendauthor = "!sh -c 'git commit --amend --author=\"$1\"' -"
amenddate = "!sh -c 'git commit --amend --date=\"$(date -R)\"'"
commitcgl = commit -m '[TASK] CGL'
# Merge
megre = merge
emrge = merge
merte = merge
# Checkout
co = checkout
# Diff
df = diff
idff = diff
doff = diff
dif = diff
worddiff = diff --word-diff
# Pull
pullall = pull --all
pullrebase = pull --rebase
# Push
pushall = push --all
# Log
logtree = log --graph --decorate --pretty=oneline --abbrev-commit
lognice = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
logme = log --author=USERNAME --pretty=format:'%h %cd %s' --date=short
logshort = log -7 --oneline
w = whatchanged
fp = format-patch
last = cat-file commit HEAD
file-blame = !git ls-files | xargs -n1 -i{} git log -1 --pretty=format:\"%ci {}\" -- {}
### search commit messages for certain word
loggrep = "!f() { git log --grep=$1; }; f"
k = !gitk
g = !gitg
# Misc
cleanup = gc
remove = rm
removeuntrackedfiles = !git clean -f -d
contributors = shortlog -s --
whois = "!sh -c 'git log -i -1 --pretty=\"format:%an <%ae>\n\" --author=\"$1\"' -"
whatis = show -s --pretty='tformat:%h (%s, %ad)' --date=short
versiontag = describe --always --long
whatthecommit = !git commit -m \"`curl -s -L http://whatthecommit.com | grep '<p>' | cut -c4-`\"
showremote = remote -v show
openremote = "open-remote"
pruneremote = remote prune origin
rebaselatest = rebase -i HEAD~9
showroot = rev-parse --show-toplevel
@pixelbrackets
Copy link
Author

pixelbrackets commented Jan 6, 2016

If you want to pick just one of these aliases you may set it like this »git config --global alias.st "status"«

In Ubuntu you may just add these lines to the file ~/.config/git/config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment