As a subversion user, git's index is the most challenging new concept I'm facing as I consider using it for new projects. I read many people's comments saying that they don't use the Index (always commit -a) but I'm thinking there might be a killer reason out there as to why I would want to make use of it. (I'm sharing code with around 5 other developers, working in a mature development environment where we merge code to test and stable branches and use branching for experimental or significant new features.)
You know that the index lets you only commit parts of the files that you want to add to the repository, of course. In general, I find it useful for this reason. I can make changes to files that sort of work, check in the parts that work, and then complete and check in the rest.
For a really killer demonstration; try using interactive add, or patch add (using git add -i
, or git add -p
). This runs through all your changes and lets you selectively add them to the index. This lets you make a whole load of changes to your files and yet split the commits. Useful for those 'aha' fixes that we all make from time to time.
Have a look at this screencast to see how it's done. Not till you try it yourself will you see how useful it is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With