Skip to content

Instantly share code, notes, and snippets.

@kaushikgopal
Created July 8, 2016 16:39
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kaushikgopal/c9cc3c2307cbfd2dfc7addd119daa7a1 to your computer and use it in GitHub Desktop.
Save kaushikgopal/c9cc3c2307cbfd2dfc7addd119daa7a1 to your computer and use it in GitHub Desktop.
KG's gitconfig
[alias]
l = !git --no-pager log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit -30
ll = !git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
la = !git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all
tree = log --oneline --decorate --graph # display git log as a tree
st = status
ss = !"ss() { git status -s | awk '{print NR,$0}' | awk -F: '{ print \"\\033[1;30m\" $1 \"\\033[0m\" }'; }; ss"
# view status of files changed
d = !"d() { git_quick_diff_with_number_from_status_changed $1; }; d" # Show the diff between the the current state and the latest commit
dc = diff --cached # show diff of changes in index
dt = difftool
mt = mergetool
c = clone --recursive # Clone a repository including all submodules
cam = commit --amend -m # change the last commit message
ccha = commit -C HEAD --amend # commit merging with last (basically use same message)
cvm = commit -vm # commit with message
cvmn = !"c() { git commit -vm \"$1\" --no-verify; }; c" # commit with message without verifying
a = !"a() { git_quick_add_from_status_changed $1; }; a"
ap = add --all -p # Staged : s - further splits : d - discard rest.
co = !"co() { git_quick_checkout_with_number_from_status_changed $1; }; co"
cob = checkout -b
go = checkout -B # switch to a branch, creating it if necessary
b = branch
ba = branch -a
rv = remote -v
tgs = tag -l # show verbose output about tags, branches or remotes
pom = push origin master
pff = pull --ff-only # Pull only if merge bubble not created (fast-forward not possible)
chp = cherry-pick
# http://stackoverflow.com/questions/11269256/how-to-name-a-stash-in-git
sshow = "!sshow() { git stash show stash^{/$*} -p; }; sshow" # show: files changed, insertions, and deletions
sapply = "!sapply() { git stash apply stash^{/$*}; }; sapply" # apply stash without dropping
r = rebase
reb = !"r() { git rebase --autosquash -i HEAD~$1; }; r" # Interactive rebase with the given number of latest commits
last = !"last() { git_changed_from_last_tag $1; }; last" # see the last time this file was changed
bolt = !"bolt() { git add .; git commit -a -m 'BOLT'; }; bolt" # a temp commit, when all tests pass
wip = !"wip() { git add .; git commit -a -m '--wip--' --no-verify; }; wip" # basically an immediate commit that u want in you reflog
# wip = !"wip() { git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit -m '--wip--' --no-verify; }; wip" # basically an immediate commit that u want in you reflog
wipa = !"wipa() { git add .; git commit -a -m '--wip--' --no-verify; }; wipa" # when you want to combine latest changes with last gwip
wipr = !"wipr() { git reset --soft HEAD~; git reset ; }; wipr" # undo last commit (works well with gwip) - watch out though
#fixup = "!f() { git commit --fixup=HEAD~$1; }; f"
#squash = "!s() { git commit --squash=HEAD~$1; }; s"
# fixlast = !"git add --all . && git commit --amend --no-edit" # see cpr
# fixlasti = !"git add --all . && git commit --fixup=HEAD~0 && git rebase --autosquash -i HEAD~2"
# [apply]
# whitespace = fix # Detect whitespace errors when applying a patch
[core]
excludesfile = ~/.gitignore # Use custom `.gitignore` and `.gitattributes`
attributesfile = ~/.gitattributes
editor = atom -n -w
whitespace = trailing-space,space-before-tab
[color]
ui = always # Use colors in Git commands that are capable of colored output when outputting to the terminal
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = magenta bold
frag = cyan bold
old = red reverse
new = green reverse
whitespace = white reverse
[color "status"]
added = red
changed = green
untracked = blue
[branch "master"] # Use `origin` as the default remote on the `master` branch in all cases
remote = origin
merge = refs/heads/master
[url "git@github.com:"] # URL shorthands
insteadOf = "gh:"
pushInsteadOf = "github:"
pushInsteadOf = "git://github.com/"
[url "git://github.com/"]
insteadOf = "github:"
[url "git@gist.github.com:"]
insteadOf = "gst:"
pushInsteadOf = "gist:"
pushInsteadOf = "git://gist.github.com/"
[url "git://gist.github.com/"]
insteadOf = "gist:"
[push]
default = tracking
[difftool "opendiff"]
cmd = studio $LOCAL $REMOTE
[diff]
tool = opendiff
mnemonicprefix = true
compactionHeuristic = true
[mergetool "opendiff"]
cmd = studio $LOCAL $REMOTE -ancestor $BASE -merge $MERGED
[merge]
log = true
tool = opendiff
stat = true
[mergetool]
keepBackup = false
[filter "lfs"]
clean = git-lfs clean %f
smudge = git-lfs smudge %f
required = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment