Skip to content

Instantly share code, notes, and snippets.

@NorthIsUp
Created May 22, 2012 19:05
Show Gist options
  • Save NorthIsUp/2770988 to your computer and use it in GitHub Desktop.
Save NorthIsUp/2770988 to your computer and use it in GitHub Desktop.
[color]
# this sets * = auto for all color sections
ui = true
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
whitespace = red reverse
[color "status"]
added = yellow
changed = green
untracked = cyan
[core]
excludesfile = /Users/<YOU>/.gitignore_global
# this line breaks updating phabricator
# whitespace = fix,tab-in-indent,trailing-space,cr-at-eol
autocrlf = input
safecrlf = warn
[status]
showUntrackedFiles = no
[branch]
autosetuprebase = always
[alias]
# add all tracked files to the index and amend the last commit
amend = commit -a --amend
# shortcut for branch
br = branch
# shortcut for commit
ci = commit
# shortcut for checkout
co = checkout
# puts the index in a detached head state
detach = checkout HEAD^0
# shortcut for diff
df = diff
# fetch all remote branches
fa = fetch --all
# shortcut for status
st = status
# shortcut for status
stat = status
# merge origin master
mom = merge origin/master
# push origin master
pom = push origin master
# blank origin master
rom = rebase origin/master
# Different log configs
lg = log --pretty=oneline --all --graph --abbrev-commit --decorate
# like lg + name of author
lw = log --graph --pretty=format:'%C(yellow)%h%Creset -%C(magenta)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
# graph + full diff
ll = log -p --graph
# graph + file stats (file ---++++++)
ls = log --stat --graph
# list all the git aliases in this file
alias = !git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1\\t=> \\2/' | sort
# show all todos, etc
notes = !git ls-files | xargs notes | awk -F: '{ print $1,$2; print $3,$4; print $5}' | grcat conf.notes
# add something to the .gitignore for this repo
ignore = !([ ! -e .gitignore ] && touch .gitignore) | echo $1 >>.gitignore
# undelete from the last commit that had a file
undelete = !git checkout $(git rev-list -n 1 HEAD -- "$1")^ -- "$1"
# add some useful ignores for python
ignore-defaults = !echo '\n*.py[co]\n*.egg\n*.egg-info\ndist\nbuild\neggs\nparts\nbin\nvar\nsdist\ndevelop-eggs\n.installed.cfg\npip-log.txt\n.coverage\n.tox\n*.mo\n.mr.developer.cfg\n.DS_Store\n._*\n.Spotlight-V100\n.Trashes\n.*.sw[a-z]\n*.un~\nSession.vim\n/*.sublime-project' > .gitignore
# make a new git repo in the current folder with a readme
this = !touch README.md && git ignore-defaults && git init && git add . && git commit -m \"initial commit\"
# open a github url for the current git repo
hub = !git remote -v|sed "'s|.*git[:@]\\(.*\\).git.*|http://\\1|;s|m:|m/|'"|uniq|xargs open
# returns the github.token
hub-token = !git config --get github.token
# returns the github.token
hub-user = !git config --get github.user
# creates a new ghithub repo with the current folder name
hub-create-repo = !curl -F "login=`git hub-user`" -F "token=`git hub-token`" -F "name=${PWD##*/}" http://github.com/api/v2/yaml/repos/create
# adds github as remote origin assuming the folder name is the repo name
hub-init-remote-add = !git init && git remote add origin "git@github.com:`git hub-user`/${PWD##*/}.git" && git fetch --all
# adds github as remote origin assuming the folder name is the repo name
hub-remote-add = !git remote add origin "git@github.com:`git hub-user`/${PWD##*/}.git"
# full git-hub creation workflow + git this
hub-this = !git this && git hub-new
# full git-hub creation workflow for existing repo
hub-new = !git hub-create-repo && git hub-remote-add && git pom
# delete current branch
chop = !zsh -c "CB=$(git branch | grep '\\*') && CB=${CB[3,-1]} && [ $CB != \"(no branch)\" ] && git checkout --detach ${1:-\"HEAD\"} && git branch -d ${CB}"
# convenience function for using phabricator's arc command
arcdiff = !git fetch --all && git rom && arc diff origin/master
switch = !legit switch \"$@\"
branches = !legit branches
sprout = !legit sprout \"$@\"
unpublish = !legit unpublish \"$@\"
harvest = !legit harvest \"$@\"
sync = !legit sync \"$@\"
publish = !legit publish \"$@\"
graft = !legit graft \"$@\"
[github]
# GitHub username
user =
# GitHub api token, keep this secret, keep it safe
token =
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment