Today, I was working with a developer at his station and we made some changes to some code. I asked if he could commit those changes, and he told me that he was not ready to commit those changes because he had made changes elsewhere in the system and those other changes were not yet ready. This reminded me of why I have made the switch to using Distributed Version Control.
You see, when you are using Distributed Version Control Systems, you can adjust your workflow in such a way that you do not run into these types of scenarios. With the advantage of creating branches of code locally, you can work on completely different efforts simultaneously. Currently I have 7 different branches that reside locally for one of my customers. This allows me to switch between different efforts that are currently underway. More than that, since I am using Git, I am able to synchronize with my customer's Subversion repository and delivery the changes that I want to delivery and retain the ones that I don't.
To illustrate the advantage of using DVCS, let's take the scenario I mentioned earlier. A developer approaches me and asks me for some help and would like to pair program a specific feature. I am smack dab in the middle of working on something (I mean the code doesn't even compile). Since I am using Git, I am able to commit this code that doesn't compile and create a new local branch based on the trunk of the source code that is in Subversion. I realize committing code that doesn't compile is a big NO-NO, but I believe that helping your co-workers / customers is much more important (besides, I would only be committing those changes locally, and not pushing them to Central repository anyways). Now the code that resides on my machine looks exactly like the code that is in the repository. We make the necessary code changes, I commit them locally to my local repository and push them back up to Subversion. My co-worker / customer goes on his merry way, and I switch back to the branch that I was working on when they came over for assistance.
DVCS...it is a beautiful thing...
2 comments:
With modern Git you can, instead of making (and then amending, rewriting or soft resetting) temporary commit, you can use git-stash to stash away changes, and then restore them when you want to go back. Note however that stash is global, not per-branch.
Other DVCS (and some CVCS) have similar solutions. It might be called shelve rather than stash.
Jakub,
I am going to have to look more closely at the stash feature of git. While I have used it in the past, I am not entirely sure how it would fit in my workflow.
At this point, I am more of the fan of "keeping the master and tracking branches clean" style of working. Therefore, I always start off with a local branch for whatever the effort may be, then merge those changes into the branch that I push into Subversion.
Since you mentioned reset, perhaps you can help me better understand when you would want to use this feature. What would be a good circumstance to use reset soft, mixed, and/or hard.
Thanks in advance...
Post a Comment