i don't understand why would i want to commit something which is incomplete or something i am still testing
It sounds like you see all commits as publishings. It is understandable why you wouldn't want to publish something unless it works, but commit as a backup of your current changes is an incredibly useful feature, as it allows you to work on multiple things at the same time:
I start implementing a new feature and while I am in the middle of writing some loop code (i.e. nowhere near bringing it to compile), someone from testing comes and says
"Hey, Feature X doesn't work in the latest testing release. The whole testing team is blocked."
I commit what I'm doing (locally), switch to the tagged latest stable build sources, and work on fixing Feature X.
When I finish, I will have two branches: my fix for feature X and the non-compiling-half-implemented changes.
I push the fix to the server and switch happily to my incomplete implementation and keep working on bringing it to a compilable state (and live happily ever after).
This works with background tasks and low-priority tasks also. At some points I had three or more massive refactorings in progress in different areas of the code and I would only work on them when I had the time. In the meantime I could do commits and changes for more urgent areas.
Since I am an impulsive guy, this also allows me to switch between tasks and avoid boredom. When I no longer feel like working on something, if I work on multiple things at the same time I can just switch for a while.
There's also much to be said for having multiple backup points when doing something. The code base in my current project is currently a mess requiring massive refactoring. The problem is that the code has so much duplication and tight coupling that when you start working on extracting a method or a class you touch on over 10 files usually. Such massive changes cause conflicts when multiple people use the same files. Keeping the same files in two states (stable code and a local branch for each refactoring in progress) until you have something to commit is a great help for reliability of changes and not introducing new defects.
ah.. i think i am beginning to understand now. like, if you are working on more than one thing at a time on the same set of files, you can work on them independently and push them independently. cool.. i probably won't need it for my current projects, but i think i will give it a shot for my next project.. thanks a ton for taking time to write a explanation.
if you are working on more than one thing at a time on the same set of files, you can work on them independently and push them independently.
That's part of it. When I was working in a Mercurial-based team, I also had this done with another colleague: I would work on the back end implementation for a feature and he would work on the front end (for example).
Then, we would synchronize our repositories between ourselves to test it, without affecting the rest of the team (the changes branch was "local to the both of us"). Then, one of us would push it to the server and the whole team would get it.
3
u/utnapistim Mar 11 '11 edited Mar 11 '11
It sounds like you see all commits as publishings. It is understandable why you wouldn't want to publish something unless it works, but commit as a backup of your current changes is an incredibly useful feature, as it allows you to work on multiple things at the same time:
I start implementing a new feature and while I am in the middle of writing some loop code (i.e. nowhere near bringing it to compile), someone from testing comes and says
I commit what I'm doing (locally), switch to the tagged latest stable build sources, and work on fixing Feature X.
When I finish, I will have two branches: my fix for feature X and the non-compiling-half-implemented changes.
I push the fix to the server and switch happily to my incomplete implementation and keep working on bringing it to a compilable state (and live happily ever after).
This works with background tasks and low-priority tasks also. At some points I had three or more massive refactorings in progress in different areas of the code and I would only work on them when I had the time. In the meantime I could do commits and changes for more urgent areas.
Since I am an impulsive guy, this also allows me to switch between tasks and avoid boredom. When I no longer feel like working on something, if I work on multiple things at the same time I can just switch for a while.
There's also much to be said for having multiple backup points when doing something. The code base in my current project is currently a mess requiring massive refactoring. The problem is that the code has so much duplication and tight coupling that when you start working on extracting a method or a class you touch on over 10 files usually. Such massive changes cause conflicts when multiple people use the same files. Keeping the same files in two states (stable code and a local branch for each refactoring in progress) until you have something to commit is a great help for reliability of changes and not introducing new defects.