Skip to content

Instantly share code, notes, and snippets.

@loctanvo
Forked from jstclair/.gitconfig-aliases
Created September 28, 2015 07:47
Show Gist options
  • Save loctanvo/c315a1b715e1e6db1a11 to your computer and use it in GitHub Desktop.
Save loctanvo/c315a1b715e1e6db1a11 to your computer and use it in GitHub Desktop.
Git aliases
[alias]
# common aliases - acquired from many places...
# operations
b = branch
cl = clone
ci = commit
amend = commit --amend --no-edit
st = status --short --branch
ai = add --interactive
co = checkout
br = branch
bra = branch -ra
branch = branch -ra
cp = cherry-pick
dt = difftool
mt = mergetool
#log
le = log --oneline --decorate
lg = log --color --graph --pretty=format:'%Cred%h%Creset%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
lds = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
ld = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative
lc = "!f() { git ll "$1"^.."$1"; }; f"
lnc = log --pretty=format:"%h\\ %s\\ [%cn]"
filelog = log -u
fl = log -u
# recent history
standup = !sh -c \"git log --pretty=format:'%C(auto)%h %B' --decorate --date=short --since=yesterday --author='$(git config --get user.email)'\"
## list modified files in last commit
dl = "!git ll -1"
## diff last commit
dlc = diff --cached HEAD^
dr = "!f() { git diff -w "$1"^.."$1"; }; f"
diffr = "!f() { git diff "$1"^.."$1"; }; f"
# find
##grep on filename
f = "!git ls-files | grep -i"
## grep from root folder
gra = "!f() { A=$(pwd) && TOPLEVEL=$(git rev-parse --show-toplevel) && cd $TOPLEVEL && git grep --full-name -In $1 | xargs -I{} echo $TOPLEVEL/{} && cd $A; }; f"
grep = grep -Ii
gr = grep -Ii
# aliases
la = "!git config -l | grep alias | cut -c 7-"
# tags
lasttag = describe --tags --abbrev=0
lt = describe --tags --abbrev=0
# objects
type = cat-file -t
dump = cat-file -p
# reset commands
r = reset
r1 = reset HEAD^
r2 = reset HEAD^^
rh = reset --hard
rh1 = reset HEAD^ --hard
rh2 = reset HEAD^^ --hard
#stash
sl = stash list
sa = stash apply
ss = stash save
#rebase
rc = rebase --continue
# misc
whoami = !git config --get user.email
ignored = ls-files --others --i --exclude-standard
#list remotes
rem="!git config -l | grep remote.*url | tail -n +2"
[alias]
# for demo
cr = !sh -c \"git commit -m '$(curl -s http://whatthecommit.com/index.txt)'\"
doit = !git add -A && git cr
# other recommended settings
# NOTE: I'm only including a few section and their values
# so you shouldn't replace your existing [core] section with below, but add if missing
# These are documented at: `git --help config` or `man git-config` (section CONFIGURATION FILES, subsection Variables)
[core]
whitespace = cr-at-eol,trailing-space,space-before-tab
[diff]
mnemonicprefix = true
context = 6
renames = copies
[i18n]
logoutputencoding = utf-8
filesEncoding = utf-8
[push]
default = simple
[pull]
default = current
[branch]
autosetuprebase = always
[rerere]
enabled = true
[credential]
helper = osxkeychain #
[advice]
statushints = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment