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 commit early and often. Small diffs are the key.
- When I’ve finished
git checkout master
git pull any 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 -i so that I squash all the commits in my branch down into one. This keeps the master branch nice and tidy.
git checkout master once the code is ready
git merge my_new_feature
git push
Continue reading