$ git config --global alias.last 'log -1 HEAD'
Aliasing from the command line
$ vim ~/.gitconfig # vim > everything else
[alias]
graph = log --graph --oneline --all --decorate
today = log --oneline --since=6am --author='Adam Giese' --all
scratch = !vim `git rev-parse --show-toplevel`/.scratchpad
Aliasing from the editor
$ git co # checkout
$ git c # commit
$ git push # push
Shorthands. Warning: May make working on another machine a living hell.
$ git remotes # remote -v
$ git stashes # stash list
$ git branches # branch -a
General git niceties
$ git create-branch # checkout -b
$ git delete-branch # checkout -D
$ git this-branch # rev-parse --abbrev-ref HEAD$ git push-branch # !git push -u origin `git this-branch`
Branching
$ git grpe # git grep
$ git grp # git grep
$ git checkoiut # git checkout
Fix typos
$ git graph # log --graph --oneline --all --decorate
$ git today # log --oneline --since=4am --author='Adam Giese' --all
$ git last # log -1 HEAD
$ git filehistory # log -p --follow --
Alias your log preferences
$ git here # rev-parse --show-prefix
$ git home # rev-parse --show-toplevel
$ cd `git home` # navigates to root of repo
Aliases for navigation
$ git oops # commit --amend --no-edit --date="now"
$ git commit-all # !git add --all && git commit
$ git pop-commit # reset --soft HEAD
$ git combine-commits # !git pop-commit && git oops
Aliases for commiting
$ git work # config user.email "adam.giese@underarmour.com"
$ git personal # config user.email "adam.giese@gmail.com"
Toggling configs
$ git undo-changes # reset --hard
$ git force-clean # clean -fd
$ git clean-all # !git force-clean && git undo-changes
Cleaning up
$ git unsnap # checkout -- '**/*.snap'
$ git todos # git grep -i todo -- ':/'
Common patterns
If you want more than a single line, you can add custom functions by adding a file named git-COMMAND
to your $PATH
count_grep() { git log --oneline --grep "$1" -i --no-merges | wc -l }
echo "# Instances of Curse Words in Commit Logs"
echo "Fuck: $(count_grep fuck)"
echo "Shit: $(count_grep shit)"
echo "Hell: $(count_grep ' hell ')"
echo "Ass: $(count_grep ' ass ')"
echo "Damn: $(count_grep damn)"
echo "Dammit: $(count_grep dammit)"
git-curses
$ git curses