Shelve extension

Peter Hosey boredzo at gmail.com
Mon Feb 23 12:22:54 CST 2009


On Feb 23, 2009, at 10:11:30, Bill Barry wrote:
> this confusing thing called the "index" (I have been trying to  
> understand what exactly it is for a month now and I still feel like  
> I've gotten nowhere except further confused)

It's your next commit. Git separates this from the working copy;  
instead of committing what's in your working copy, you add changes to  
the index, then commit what's there.

The index is really good for being able to commit separate changes as  
separate commits (the mixed-working-copy problem). Not only do you  
have interactive hunk selection (the record extension in hg; add -i in  
Git), but you don't have to commit them in the same operation like you  
do with hg record—instead, Git saves those selections in the index.  
You have all the time in the world to review the changes, add changes,  
remove changes (not interactively, unfortunately), review again, etc.  
until you commit.

So you can, for example:

1. Add some changes to the index.
2. Go for lunch.
3. Review the index and working copy.
4. Find that you missed a change that should be in the index.
5. Add that.
6. Refill your coffee/tea/soda/water container.
7. Commit the index.
8. Review the working copy.
9. Add the rest of the changes.
10. Commit #2.

I'm certainly not a frequent Git user, but I do think the index is its  
most important contribution to the field of version control.




More information about the Mercurial mailing list