Home

Awesome

git-smart

git-smart logo

Adds some additional git commands to add some smarts to your workflow. These commands follow a few guidelines:

  1. It should do the 'right thing' in all situations - an inexperienced git user should be guided away from making simple mistakes.
  2. It should make every attempt to explain to the user what decisions it has made, and why.
  3. All git commands that modify the repository should be shown to the user - hopefully this helps the user eventually learn the underlying git commands, and when they're relevant.

Installing

All you need to do is grab the gem:

gem install git-smart

This will add an executable for each command, e.g. git-smart-pull. You call them using git's simple syntax for custom commands, e.g. git smart-pull. They'll be removed when you uninstall the gem.

You almost certainly want to run this as well, to allow git commands to be output with colour:

git config --global color.ui always

Git normally only colours output when being run from the terminal, not from within scripts like these. This sorts that right out.

Get smart!

There's only three commands at this point, but there'll be more!

smart-pull

Run git smart-pull whenever you would have run git pull. It doesn't take any arguments, it'll use the tracking branch configuration or assume 'origin/same-branch-name'.

In brief, it'll detect the best way to grab the changes from the server and update your local branch, using a git rebase -p if there's no easier way. It'll also stash/pop local changes if need be.

Read what it does in detail: smart-pull

Recommended alias to use: gup

smart-merge

Run git smart-merge when you would have run git merge. This is basically a wrapper around git merge --no-ff, which should have been the default anyway. It also does a stash/pop if required, and reports a bit of helpful output.

Details here: smart-merge

Recommended alias to use: gm

smart-log

Big hat tip to @ben_h for this one - it's an alias to a completely badass git log format that not many people know about.

Details here: smart-log

Recommended alias to use: gl

Contributing to git-smart

Copyright

Copyright (c) 2011 Glen Maddern and Envato Pty Ltd. See LICENSE.txt for further details.