I’ve been a Git convert, and version control geek, for over a year now so I’ve sort of become the unofficial Git consultant at the office. If anythings breaks or something weird happens I’m usually the one called in to sort it out.
In order to preserve at least some of the remnants of our sanity I decided, after my colleague managed to corrupt his entire local repository, that I needed to enforce some sort of system. What I finished up with is this fairly typical workflow:
- Find a feature (or bugfix, ticket, etc.) to work on
git checkout -b my_new_feature
- Hack away at some code
git commitearly and often. Small diffs are the key.
- When I’ve finished
git checkout master
git pullany changes
git checkout my_new_feature
git rebase master
- Fix any merge conflicts that I may have. If there are conflicts, fix them and keep going. Merge conflicts should be kept off the master branch if at all possible.
git rebase -iso that I squash all the commits in my branch down into one. This keeps the master branch nice and tidy.
git checkout masteronce the code is ready
git merge my_new_feature
Once our code is ready for staging we push our code to the
staging branch, and likewise to the
production branch. The
master branch is reserved for bleeding edge code.
I then started thinking, surely there must be a much easier way to manage this workflow? A minimum of seven separate commands to merge my changes into
master and push it back to the server?
Flit is a command line utility that eases the typical Git workflow that I’ve outlined above. Setting up Flit to work with either a new or existing Git repository is a simple as
flit init. If you haven’t already created a Git repository then Flit will create one for you.
Then, whenever you want to start, or continue with, a feature or bugfix simply do
flit start feature my_new_feature. Flit will create, or switch, to your feature branch, ready for you to start hacking away.
You can then use Git as normal, committing your changes as and when you see fit. Once you’ve finished work for the day on your feature or bugfix,
flit stop will return you back to your development branch.
Once your feature is complete
flit finish feature my_new_feature will pull down changes in
master, rebase them into your feature branch and then merge your feature back into
Flit is an extremely early alpha. Features may be broken or just plain missing, but getting this code out into the open-source community where people can start hacking away with it is much more important.
To that end, the entire codebase is hosted on GitHub. If something’s missing just fork the code, add your fix and send me a pull request.
- Git 1.6.4 or greater
- Ruby 1.8.7 or greater
The easiest way to install Flit is through RubyGems:
gem install flit --pre
Alternatively you can install Flit from source:
rake gem && rake install