by chousuke · 15y ago · 0 comments
Git provides a wealth of tools to craft perfect commits, and if you use them, it's not difficult to end up with a nice history of "add this, remove that, modify something else" changesets that (usually) would make sense even when separated from the surrounding history.
Pointers please?
In short, the index allows you to decide what goes in a single commit, regardless of the actual contents of a working directory. You can commit only a single line from a file if you want. If you learn how the index works and why it works like it does, understanding the rest becomes much easier.
You can also eg. resolve a conflict piece-by-piece by adding resolved parts to the index, diffing against the working directory, and then finally committing once the content of the index looks correct.
There are many tutorials and I'm not sure which one is the best but I think the book "Pro Git" does a good job at explaining the index among other things. It's freely available online at http://progit.org