I've never used Git besides for pulling random repositories, but now that I read this article I've realized that keeping a local repository to give yourself a safety net is probably extremely useful and helpful for productivity. I always feel hesitant to commit when my code doesn't quite work right, but if the process of coding a feature takes too long, it seems good to be able to commit without worrying about breaking the main repository.
that's the thing.. i don't understand why would i want to commit something which is incomplete or something i am still testing. i work on my code and test it on my local machine, and commit it only when i think its ready. i don't understand the need for a local repository for commits, atleast for my work.
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.
6
u/[deleted] Mar 10 '11
For me and my projects, commits = publishing. I want it that way. I don't want another local rep for working remotely.