Skip to content

Instantly share code, notes, and snippets.

@adamzaninovich
Last active December 20, 2015 16:09
Show Gist options
  • Save adamzaninovich/6159876 to your computer and use it in GitHub Desktop.
Save adamzaninovich/6159876 to your computer and use it in GitHub Desktop.
Some helpful git functions
# g: with no args: runs short status
# with args: acts as `git`
function g () {
if [[ $# > 0 ]]
then
git $@
else
git status -sb
fi
}
# gl: pretty git log
function gl () {
git log --pretty=format:'%Cred%h%Creset -%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'
}
# gd: open basic diff in macvim (change `mvim -f` to `subl -w` for sublime)
function gd () {
local tempfile='/tmp/tmp_git_diff.diff'
git diff $@ > $tempfile && mvim -f $tempfile
}
# qa: with no args: adds all changes
# with args: acts like `git add`
function ga () {
if [[ $# > 0 ]]
then
git add $@
else
git add --all
fi
}
# qc: with no args: opens commit editor with diff in your default editor (set EDITOR="subl -w" for sublime, EDITOR="mvim -f" for macvim)
# with args: accepts a message as bare words (no quotes needed). ie: `gc added something awesome`
function gc () {
if [[ $# > 0 ]]
then
git commit -m "$*"
else
git commit -v
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment