Skip to content

Instantly share code, notes, and snippets.

@jwheare
Last active September 25, 2015 01:27
Show Gist options
  • Save jwheare/840273 to your computer and use it in GitHub Desktop.
Save jwheare/840273 to your computer and use it in GitHub Desktop.
Useful shortcuts/colorisation for git
# Not really git related, this is for ls colors, put in e.g. ~/.bash_login
export CLICOLOR="true"
export LSCOLORS="DxfxexdxCxegedabagacad"
# Put in ~/.gitconfig
[core]
excludesfile = ~/.gitignore
whitespace = -blank-at-eol,space-before-tab,-indent-with-non-tab,blank-at-eof,cr-at-eol
[color]
ui = auto
showbranch = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow
frag = cyan bold
old = red bold
new = green bold
commit = yellow
whitespace = white red
[color "status"]
added = yellow
changed = green
untracked = cyan
[color "interactive"]
prompt = yellow
header = green
help = cyan
error = magenta
[color "decorate"]
branch = yellow ul
remoteBranch = green
tag = magenta
stash = green
HEAD = cyan
[color "grep"]
context = white
filename = yellow
function = green
linenumber = cyan
match = yellow reverse
selected = normal
separator = magenta
[alias]
ci = commit
co = checkout
[push]
default = current
[branch]
autosetuprebase = always
# Git
source ~/.git-completion.bash
source ~/.git-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWSTASHSTATE=1
export GIT_PS1_SHOWUNTRACKEDFILES=1
export GIT_PS1_SHOWUPSTREAM="auto"
export GIT_PS1_SHOWCOLORHINTS=1
alias gst="git status -sb"
alias glo="git log --decorate --oneline"
alias ggr="git grep -i -np"
alias gdw="git diff --word-diff"
gdf() { git diff "$@" | subl --stay; }
gdc() { git diff --cached "$@" | subl --stay; }
alias gsh="git stash"
alias gpo="git stash pop"
alias gap="git add -p"
alias gci="git commit"
alias gam="git commit --amend"
alias gre="git reset"
__git_complete gco _git_checkout
alias gbr="git branch"
alias gbra="git branch -a"
alias gcp="git cherry-pick"
alias grb="git rebase -i"
alias gps="git push && (git remote | grep server) && git push server"
gpu() {
stashlist="$(git stash list)"
if [ "$stashlist" ]; then
echo "Already stashed changes"
echo $stashlist
return 1;
fi
git stash && git pull && git stash pop;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment