Skip to content

Instantly share code, notes, and snippets.

@ajesler
Created December 13, 2013 02:13
Show Gist options
  • Save ajesler/7938898 to your computer and use it in GitHub Desktop.
Save ajesler/7938898 to your computer and use it in GitHub Desktop.
My .gitconfig file
[user]
name = <NAME>
email = <EMAIL>
[credential]
helper = cache --timeout=43200
[core]
editor = nano
#pager = less -r
# aliases based on https://github.com/durdn/cfg/blob/master/.gitconfig
[color]
branch = auto
diff = auto
status = auto
[color "branch"]
current = red bold
local = green
remote = cyan
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
[color "status"]
added = yellow
changed = green
untracked = cyan
# this is useful as it allows resuse of the pretty format
[pretty]
olpc = "%C(green)%h %C(yellow)[%ad]%Cred%d %Creset%s%C(cyan) [%cn]%Creset"
olpcnc = "%h [%ad]%d %s [%cn]"
[alias]
## MISC
g = gui
co = checkout
cl = clone
#list all aliases
la = "!git config -l | grep alias | cut -c 7-"
cp = cherry-pick
standup = log --since '1 day ago' --oneline --author <EMAIL>
## PULL
pu = pull
pur = pull --rebase
## STATUS
s = status
std = status -s
bd = status -sb
## COMMIT
ci = commit
cm = commit -m
cma = commit -a -m
ca = commit --amend
amend = commit --amend
caa = commit -a --amend -C HEAD
ai = add --interactive
## BRANCH
b = branch
b = branch -v
br = branch -r
bra = branch -ra
bm = branch --merged
bnm = branch --no-merged
## LOG
ls = log --format=olpc --decorate --date=relative
ld = "!f() { git show --format=olpc --decorate --date=relative $(git log -1 --pretty="%H" -- $1); }; f"
lb = log --oneline --decorate
lg = log --format=olpc --decorate --date=short --graph
ll = log --format=olpc --decorate --stat --abbrev-commit
lctt = "!f() { git show $(git log -1 --pretty="%H" -- $1); }; f"
#list modified files in last commit
lcf = "!git ll -1"
## DIFF
dw = diff --word-diff=color
d = diff
dc = diff --cached
ds = diff --staged
dlc = diff --cached HEAD^
# show content (full diff) of a commit given a revision
lc = "!f() { git ll "$1"^.."$1"; }; f"
dr = "!f() { git diff "$1"^.."$1"; }; f"
diffr = "!f() { git diff "$1"^.."$1"; }; f"
## COMPARING BRANCHES
# show commits in $1 but not in $2 - in a not b
ianb = "!f() { echo \"## Commits in $1 but not in $2:\" && git log \"$2\"..\"$1\" --format=olpc --decorate; }; f"
# show commits in $1 but not in $2 with no output coloring
ianbnc = "!f() { echo \"## Commits in $1 but not in $2:\" && git log \"$2\"..\"$1\" --format=olpcnc --decorate; }; f"
# show commits in $1 but not in $2 - in a not b, and show the diff
ianbwd = "!f() { echo \"## Commits in $1 but not in $2:\" && git log \"$2\"..\"$1\" --format=olpc --decorate -p; }; f"
comp = "!f() { git --no-pager ianb \"$1\" \"$2\" && git --no-pager ianb \"$2\" \"$1\"; }; f"
compnc = "!f() { git --no-pager ianbnc \"$1\" \"$2\" && git --no-pager ianbnc \"$2\" \"$1\"; }; f"
compwd = "!f() { git --no-pager ianbwd \"$1\" \"$2\" && git --no-pager ianbwd \"$2\" \"$1\"; }; f"
compcm = "!f() { git comp HEAD master; }; f"
compcd = "!f() { git comp HEAD develop; }; f"
ahm = !git --no-pager log origin/master..HEAD --abbrev-commit --format=olpc --date=relative
ahmnc = !git --no-pager log origin/master..HEAD --abbrev-commit --format=olpcnc --date=relative
ahd = !git --no-pager log origin/develop..HEAD --abbrev-commit --format=olpc --date=relative
ahdnc = !git --no-pager log origin/develop..HEAD --abbrev-commit --format=olpcnc --date=relative
## FILES
fl = log -u
## RESET
r = reset
r1 = reset HEAD^
r2 = reset HEAD^^
rh = reset --hard
rh1 = reset HEAD^ --hard
rh2 = reset HEAD^^ --hard
undo = reset --soft HEAD^
## STASH
sl = stash list
sa = stash apply
ss = stash save
sd = stash show -u
sp = stash pop
## SEARCH
grep = grep -Ii
gr = grep -Ii
#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 on filename
f = "!git ls-files | grep -i"
## ASSUME
assume = update-index --assume-unchanged
unassume = update-index --no-assume-unchanged
#show assumed files
assumed = "!git ls-files -v | grep ^h | cut -c 3-"
#unassume all the assumed files
unassumeall = "!git assumed | xargs git update-index --no-assume-unchanged"
assumeall = "!git st -s | awk {'print $2'} | xargs git assume"
## TAGS
lt = describe --tags --abbrev=0
## MERGES
ours = "!f() { git co --ours $@ && git add $@; }; f"
theirs = "!f() { git co --theirs $@ && git add $@; }; f"
[push]
default = upstream
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment