Skip to content

Add some smarts to your git workflow

License

Notifications You must be signed in to change notification settings

platforms/git-smart

 
 

Repository files navigation

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

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright

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

About

Add some smarts to your git workflow

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%