Skip to content

Instantly share code, notes, and snippets.

@kareraisu
Last active June 30, 2017 19:10
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 kareraisu/f3814562382ac1ccdfc581286269c161 to your computer and use it in GitHub Desktop.
Save kareraisu/f3814562382ac1ccdfc581286269c161 to your computer and use it in GitHub Desktop.
handy git aliases
[push]
default = simple
[alias]
l = log --pretty=format:"%ad\\ %Cblue%h%Cred%d\\ %Cgreen%s\\ %Cblue[%cn]" --graph --decorate --date=short
# list aliases
la = "!git config -l | grep alias | cut -c 7- #"
a = add
ap = add -p
b = "!git for-each-ref --sort=-committerdate refs/heads --format='%(HEAD)%(color:yellow)%(refname:short)|%(color:bold green)%(committerdate:relative)|%(color:blue)%(subject)|%(color:magenta)%(authorname)%(color:reset)'|column -ts'|' #"
ba = branch -va --sort=-committerdate
br = branch -vr --sort=-committerdate
c = commit --verbose
ca = commit -a --verbose
cm = commit -m
cam = commit -a -m
co = checkout
cob = checkout -b
d = diff --stat
dd = diff --diff-filter=ad
dc = diff --diff-filter=ad --cached
f = fetch
fa = fetch -a
# fetch and reset (must specify remote/branch)
fr = "!git fa && git reset --hard $1 #"
m = commit --amend --no-edit
mm = commit --amend --verbose
r = "!git reset HEAD~$1 #"
rs = "!git reset --soft HEAD~$1 #"
rh = "!git reset --hard HEAD~$1 #"
rb = rebase
rbi = rebase -i
s = status -s
sb = status -sb
sup = "!git f && git s #"
# squash last x commits with a new message
squash = "!git rs $1 && git cm \"$2\" #"
# squash last x commits and merge all messages
squashm = "!git rs $1 && git c --edit -m\"$(git log --format=%B --reverse HEAD..HEAD@{1})\" #"
# for initializing new repos
rao = remote add origin
ac = "!git a . && git cam #"
pall = push -u origin --all
# update local branch (must specify remote/branch)
u = "!git f && git rb $1 #"
# (fast and dirty) remote update (may specify remote/branch)
ru = "!git a . && git m && git push -f $1 #"
# temporarily ignore changes on a file
drop = update-index --assume-unchanged
pickup = update-index --no-assume-unchanged
# deploy to heroku
h = git ru heroku
# deploy subdir to heroku
hdir = "!echo 'Deploying to heroku...' && cd ~/PATH/TO/SUBDIR/ && git init && git add . && git commit -qm 'YOUR MSG' && git push -f https://git.heroku.com/YOUR-APP.git master && rm -rf .git && heroku open --app YOUR-APP #"
# dual push to origin and heroku
pp = "!git push && git h #"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment