Fine-grained Commits is the Git Way of Doing Things
Coming from a Subversion background, where I used to make bulk commits, when I first started using Git I tended to use the "-a" flag a lot, i.e., committing what usually was a broad range of edits en masse. I realize now that this is not the best use of Git. Far better to selectively stage files for a particular commit and then commit them with a specific and detailed message, repeating the process in fine-grained batches like this until all the changes in the working tree are indexed.
For example, say you are working on a test harness, and a trial run of one of the tests reveals a minor bug in your main code tree. You fix it on the spot, perhaps editing a couple of files to do it. Maybe while fixing the bugs, you had to change a function signature, which meant that some client code in another file had to be changed. Instead of then issuing a "git commit -a" which would then commit the new code in your test harness as well as the three code files you fixed, ideally you might want to break down the commit into separate ones:
$ git add package/tests/testfeatures1.py $ git commit -m "adding test of feature1 using unfriendly data" $ git add package/module1.py package/module2.py $ git commit -m "fixing bug that caused aggressive response when seeing unfriendly data" $ git add package/client.py $ git commit -m "changed calling of module1.func() to accomodate new arguments required" $ git push origin
Of course, depending on my mood, laziness, stress levels and deadlines, there is good chance that I will just:
$ git commit -a -m "various fixes" ; git push origin
... but at least the thought is there.
feed
Post new comment