Skip to content

Instantly share code, notes, and snippets.

@clamstew
Created October 18, 2013 14:42
Show Gist options
  • Save clamstew/7042573 to your computer and use it in GitHub Desktop.
Save clamstew/7042573 to your computer and use it in GitHub Desktop.
Jeff Felchner's dotfiles that has his shortcuts for git
[core]
quotepath = false
editor = vim -f
whitespace = trailing-space,space-before-tab
[branch]
autosetupmerge = false
autosetuprebase = remote
[difftool "araxis2way"]
cmd = compare -wait -2 "$LOCAL" "$REMOTE" "$MERGED"
[mergetool "araxis2way"]
cmd = compare -wait -2 "$LOCAL" "$REMOTE" "$MERGED"
[difftool "araxis3way"]
cmd = compare -wait -3 "$LOCAL" "$BASE" "$REMOTE" "$MERGED"
[mergetool "araxis3way"]
cmd = compare -wait -3 "$LOCAL" "$BASE" "$REMOTE" "$MERGED"
[difftool "mvim"]
cmd = mvim -d -g $LOCAL $REMOTE
[mergetool "mvim"]
cmd = mvim -d -g $LOCAL $MERGED $REMOTE
[difftool "vim"]
cmd = vim -d $LOCAL $REMOTE
[mergetool "vim"]
cmd = vim -d $LOCAL $MERGED $REMOTE
[difftool "diffmerge"]
cmd = diffmerge --merge --result=$MERGED $LOCAL $BASE $REMOTE
trustExitCode = false
[diff]
tool = vim
renames = copies
mnemonicprefix = true
context = 10
dirstat = changes
algorithm = patience
[difftool]
keepBackup = false
[interactive]
singlekey = true
[rerere]
enabled = true
autoupdate = true
[merge]
tool = vim
log = true
verbosity = 1
[mergetool]
keepBackup = false
[grep]
lineNumber = true
patternType = perl
[apply]
whitespace = nowarn
ignorewhitespace = change
[advice]
pushNonFastForward = false
statusHints = false
detachedHead = false
[clean]
requireForce = false
[color]
ui = true
branch = true
decorate = true
grep = true
interactive = always
pager = true
showbranch = true
diff = true
status = true
branch = true
[color "branch"]
current = white bold
local = yellow bold
remote = green bold
upstream = blue bold
[color "diff"]
plain = white bold
meta = normal
frag = magenta bold
func = cyan bold
old = red bold
new = green bold
whitespace = white bold red
[color "grep"]
filename = normal
separator = normal
match = yellow bold
linenumber = white
selected = white bold
context = normal
[color "status"]
header = white bold
added = green
changed = blue
untracked = white
branch = white bold
nobranch = red
[color "interactive"]
prompt = yellow bold
help = blue
error = red bold
[pull]
rebase = true
[push]
default = tracking
[status]
showUntrackedFiles = all
relativePaths = false
[rebase]
autosquash = true
[help]
autocorrect = 30
;***
; Special Applicaiton-Specific Configs
;
;***
; Git Flow
;
[gitflow "branch"]
master = master
develop = development
[gitflow "prefix"]
feature = feature/
release = release/
hotfix = hotfix/
support = support/
versiontag = release/
;***
; Aliases
;
[url "git://github.com/"]
insteadOf = 'ghg:'
[alias]
# GitHub
ghc = "!_temp_git() { git clone git://github.com/$1/$2.git }; _temp_git"
hub = !echo 'https://github.com/'`git config remote.origin.url` | sed -E s/[a-z]+@github\\.com:// | sed s/\\.git$//
url = !echo `git hub`'/commit/'`git rev-parse HEAD`
tiny = !curl "http://tinyurl.com/api-create.php?url=$(git url)"
# Committing
c = commit -vm
ca = commit -avm
amend = commit -v --amend
cp = cherry-pick
white = commit -vm "Whitespace"
credit = "!_temp_git() { git commit --amend --author \"$1 <$2>\" -C HEAD; }; _temp_git"
s = status
rs = remote show origin
# Submodules
sm = submodule
sub = submodule update --init --recursive
# Adding
a = add
aa = add -A
ap = add --patch
resolve = add -u
# Branches
b = branch -avv
mkb = checkout -b
rmb = "!_temp_git() { git branch -D $1; git push origin :refs/heads/$1; }; _temp_git"
rmlb = branch -D
rmrb = "!_temp_git() { git push origin :refs/heads/$1; }; _temp_git"
cltb = checkout -t
crtb = push -u origin
ccrtb = !git push -u origin `git name-rev --name-only HEAD`
# Checkout
co = checkout
cop = checkout --patch
# Switching Branches
sw = checkout
dev = checkout development
mstr = checkout master
# Tags
t = tag -s
rmt = "!_temp_git() { git tag -d $1 && git push origin :refs/tags/$1; }; _temp_git"
releases = !git tag | grep --color=never release
passed = !git tag -a -m 'On this commit all tests passsed' test-suite/passed/`date +%Y%m%d%H%M%S` && git push --tags origin
failed = !git tag -a -m 'On this commit one more tests failed' test-suite/failed/`date +%Y%m%d%H%M%S` && git push --tags origin
# Stashing
wip = stash save -a -u 'wip'
unwip = !git stash pop --quiet && git reset --quiet HEAD && git status
rewip = !git unwip && git wip
stu = "!_temp_git() { git stash show -p $1 | git apply -R; }; _temp_git"
st = stash
sts = stash save
stl = stash list
stp = stash pop
sta = stash apply
std = stash drop
stsh = stash show -p
# Workflow
up = "!_temp_git() { local no_change='foo'; if [[ `git status` =~ nothing.to.commit ]]; then no_change=1; fi; if [[ $no_change == 1 ]]; then echo 'No local changes. Skipping stash.'; else git aa; git wip; fi; git fa; git rebase --preserve-merges origin/`git name-rev --name-only HEAD` && if [[ $no_change == 1 ]]; then echo 'No local changes. Skipping stash pop.'; else git unwip; fi; }; _temp_git"
cleanup = "!_temp_git() { git aa && git stash save \"safety net\" && git rh && git clean -dfx -e *.staging -e *.princess -e *.production; }; _temp_git"
terminate = "!_temp_git() { echo 'You are doing something potentially ridiculous. Maybe you just want to clone the repo into another directory?'; read -p 'Press any key to continue or ^C to abort...'; git remote prune origin && git cleanup && git stash clear && git gc; }; _temp_git"
backmerge = "!_temp_git() { local no_change='foo'; local current_branch=`git name-rev --name-only HEAD`; if [[ `git status` =~ nothing.to.commit ]]; then no_change=1; fi; if [[ $no_change == 1 ]]; then echo 'No local changes. Skipping stash.'; else git aa; git stash -a -u -q; fi; echo \"Backmerging '$current_branch' into '$1'\" && git sw $1 && git mm $current_branch && git rmb $current_branch && if [[ $no_change == 1 ]]; then echo 'No local changes. Skipping stash pop.'; else git stash pop --quiet && git reset --quiet HEAD; fi; }; _temp_git"
mbubble = "!_temp_git() { git mm $1 -m \"Merge branch '$2' into `git name-rev --name-only HEAD`\"; }; _temp_git"
# Code Review
review = "!_temp_git() { git rvstart $1 && git rvfinish; }; _temp_git"
rvstart = "!_temp_git() { local no_change='foo'; local current_branch=`git name-rev --name-only HEAD`; if [[ `git status` =~ nothing.to.commit ]]; then no_change=1; fi; if [[ $no_change == 1 ]]; then echo 'No local changes. Skipping stash.'; else git aa; git stash -a -u -q; fi; git cltb origin/$1 && git rb development; if [[ $no_change == 1 ]]; then echo 'No local changes. Skipping stash pop.'; else git stash pop --quiet && git reset --quiet HEAD; fi; }; _temp_git"
rvfinish = "!_temp_git() { local current_branch=`git name-rev --name-only HEAD`; git sw development && git mm $current_branch && git rmb $current_branch; }; _temp_git"
# Diff / Merge
d = diff --ignore-space-change
dc = diff --ignore-space-change --cached
ds = diff --ignore-space-change --stat
dl = diff --ignore-space-change head~1..head
dls = diff --ignore-space-change head~1..head --stat
dt = difftool
m = merge
mm = merge --no-ff
mt = mergetool
mod = merge origin/development
mos = merge origin/staging
mom = merge origin/master
# Reset
u = reset head~1
uh = reset --hard head~1
rh = reset --hard
unstage = reset HEAD --
# Rebase
rb = rebase --preserve-merges
rbd = rebase --preserve-merges development
rbi = rebase -i
rba = rebase --abort
rbc = rebase --continue
rbs = rebase --skip
# Bisect
bi = bisect
bis = bisect start
bir = bisect run
big = bisect good
bib = bisect bad
birt = bisect reset
# Log
bl = blame -w -M -CCC
l = log
lc = log ORIG_HEAD.. --stat --no-merges
lg = log --graph --pretty=format:'%Cred%h%Creset - %Cgreen(%ad) %C(bold blue)%an%Creset %s%Creset%C(yellow)%d%Creset' --abbrev-commit --date=local
lga = !git lg --all --full-history
last = !git --no-pager lg -25
flog = log --follow --full-history -p
orphans = "!_temp_git() { local dangling=$(git fsck --dangling --no-reflog | awk '/dangling commit/ {print $3}'); local unreachable=$(git fsck --unreachable --no-reflog | awk '/unreachable commit/ {print $3}'); local all=\"${dangling}\n${unreachable}\"; all=$(echo \"$all\" | sort -u); echo \"$all\" | git show --format='SHA1: %C(red)%h%Creset:%C(green)%ci%Creset:%C(blue)%an%Creset:%s' --stdin | awk '/^[^+|\\-]/' | awk '/^SHA1/ {sub(\"SHA1: \", \"\"); print}' | sort -t: -k2 | less -R; }; _temp_git"
today = log --stat --since='1 Day Ago' --graph --pretty=oneline --abbrev-commit --date=relative
heads = !"git log origin/master.. --format='%Cred%h%Creset;%C(yellow)%an%Creset;%H;%Cblue%f%Creset' | git name-rev --stdin --always --name-only | grep -v tags/ | column -t -s';'"
sha = !"git rev-parse HEAD | tr -d \"\n\" | pbcopy"
bn = !"git name-rev HEAD --name-only | tr -d \"\n\" | pbcopy"
# Fetching
fa = fetch --all --verbose
fo = fetch --verbose origin
# Pushing
p = push
fpoc = !git fpo `git name-rev --name-only HEAD`
fpo = "!_temp_git() { if [ -z \"$1\" ]; then echo Must specify a branch name to push to; exit; fi; git fetch --dry-run origin 2>&1 | grep --color=never -E $1; if [ $? -ne 0 ]; then git push --force origin $1; else echo \"The origin pointer for $1 has changed, fetch changes from the remote, make sure everything is rebased properly and then force push again.\"; fi }; _temp_git"
pod = push --tags origin development
pom = push --tags origin master
poc = !git push --tags origin `git name-rev --name-only HEAD`
po = push origin # --follow-tags
pt = push --tags origin # --follow-tags
# Purging
purge-file = "!_temp_git() { git filter-branch --index-filter 'git rm --cached --ignore-unmatch $1'; }; _temp_git"
# Remotes
r = remote -v
prune-remotes = "!for remote in `git remote`; do git remote prune $remote; done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment