My .bash_profile, sourcing git-completion.bash to get autocomplete for git itself and git-flow-completion.bash to get autocomplete for git-flow, along with two single character shortcuts for the most common shortcuts (s for `git status`, d for `git diff`). And my .gitconfig, among regular config and customizing colored output also defining a bunch of aliases:
The export line configures bash to show the current directory (full path!), and, if in a repository, the repository type and current branch, looking something like this: ~/dev/qunit [git:master] $
For that to work, `vcprompt` needs to be installed. If you’re using homebrew:
`brew install vcprompt`
The last line in the .bash_profile overrides the `git` command to point at hub, which wraps `git` to provide a few additional commands that make it easier to work with GitHub projects. Among others, it infers projects based on the current git repository and its remotes, powering the git-fork alias, which I use whenever I test and merge pull requests. Say someone named `beefheart` sends a pull request for jquery/qunit. All I do to get his remote is this:
`~/dev/qunit [git:master] $ git fork beefheart`
So much easier then trying to put together the correct .git URL for his fork, then wrapping that with the right invocation of `git remote add -f`.
Another GitHub specific command is ghpages: It assumes you’re on master, pulls changes, checks out the gh-pages branch, merges master and pushes those changes, then checks out master again. Useful if you keep a 1:1 copy of your master branch as a gh-pages preview.
Other aliases I use all day:
- `git cm “Message 123″` to commit all updated files without having to launch an editor
- `git br` and `git co` to create, switch and delete branches
- `git lp` to see commits with diffs
- `git lg` to see a kind-of tree view of commits – will show the commits a merge commit added directly after that merge commit, instead of the usual chronological order of `git log`. Very useful to review a banch of merges.
- `git undo` to revert bad merges
- `git co .` to revert all changed files
Some more git related tools are provided by git-extras, where I now use git-changelog to create the release notes for QUnit.
I use iTerm 2 on OSX, if nothing else, for the ability to easily display multiple terminals side by side.
If you use ZSH, apparently you can get a lot of this bundled via oh-my-zsh.