There are a lot of git workflows out there. This is mine, based on working with Git for 10-something years now. It makes use of
git rebase, so turn away now if you’re scared of rebasing (and then go read this and realize it’s just another tool). BONUS: be sure to check out my handy git helpers too!
I created this rakefile of git tasks back when I was working with a dev team that relied heavily on rake. My reasoning was that since I was already doing
rake deploy:staging and the like all the time (they preferred Screwcap to Capistrano), I might as well do
rake git:merge_and_deploy too. This works especially well with a text expander or bash alias, where you can setup
rg: to expand to
rake git: or
rug: to become
rake username:git: if you want to further namespace out these functions.
The tools I use here also work well by themselves or in their own aliases. Use this collection as a starting point for further customizing your workflow, or use as is for a quick but complete solution.
Here are the libraries I used in this rakefile:
Links to some amazing Git helpers and things.
Git-Smart and Legit have good install instructions. Here’s how to install the other scripts (which are all just shell scripts compatible with bash, zsh, probably others):
Git Extras and Git Utils can both be installed using Brew as well:
brew install git-extras git-utils
Github has an awesome feature that allows you to see a visual diff log of all of the changes between two commits. Learned how to do it on the command line today.
Here’s how to see the changes you’ve made in your repo between two commits (from the official Git docs):
git diff OLDER_COMMIT NEWER_COMMIT
Technically, you can use this to compare branches and tags too. Here’s a handy shortcut for comparing your most recent commit with the commit right before it:
git diff HEAD^ HEAD
Especially handy if, like me, you forgot what you just finished working on (or, more likely, if you haven’t worked on something for a couple days/weeks).