Skip to content

Instantly share code, notes, and snippets.

@kkumler
Last active August 29, 2015 14:00
Show Gist options
  • Save kkumler/11432459 to your computer and use it in GitHub Desktop.
Save kkumler/11432459 to your computer and use it in GitHub Desktop.
Bash git aliases (pared down)
[alias]
# Mostly: ff, unstage, hanging
co = checkout
ff = merge --ff-only
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
cat = cat-file -p
# Show changes just fetched
lc = log ORIG_HEAD.. --stat --no-merges
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
graphviz = "!f() { echo 'digraph git {' ; git log --pretty='format: %h -> { %p }' \"$@\" | sed 's/[0-9a-f][0-9a-f]*/\"&\"/g' ; echo '}'; }; f"
unstage = reset HEAD --
hanging = branch -r --no-merged
function make-completion-wrapper () {
local function_name="$2"
local arg_count=$(($#-3))
local comp_function_name="$1"
shift 2
local function="
function $function_name {
((COMP_CWORD+=$arg_count))
COMP_WORDS=( "$@" \${COMP_WORDS[@]:1} )
"$comp_function_name"
return 0
}"
eval "$function"
#echo $function_name
#echo "$function"
}
# Normally wrapped in interactive session check
# git
alias g='git'
alias ga='git add'
alias gb='git branch'
alias gc='git commit'
alias gd='git diff --minimal'
alias gdc='git diff --cached --minimal'
alias gf='git fetch'
alias gfp='git fetch --prune'
alias ggs='git stash'
alias go='git checkout'
alias gs='git st'
alias gsh='git show'
alias gi='git log -n1'
alias gl='git log'
complete -o default -o nospace -F _git g
# Get completion for our alias as well
make-completion-wrapper _git _k_git_log git log
complete -F _k_git_log gl
make-completion-wrapper _git _k_git_branch git branch
complete -F _k_git_branch gb
make-completion-wrapper _git _k_git_checkout git checkout
complete -F _k_git_checkout go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment