git annoyances: how to force git to fetch a particular file

Mike McCormack mike at codeweavers.com
Wed Jul 12 00:18:28 CDT 2006


Dan Kegel wrote:

>> git diff-index -p HEAD > foo.diff
> 
> /me goes off to read up on the -index commands, which are news to me.

You've probably figured it out already, but for anybody else...

The git "index" can be thought of as a record of what's checked out, or 
the thing you're about to commit.  If the index is the same as the HEAD 
branch, you won't commit any changes when you run "git commit".  If it's 
different, you will commit changes.  "git status" gives a nice summary 
of that.

You change the git index with "git update-index". eg.

git update-index --add foo.c     # add foo.c to the index
git update-index --remove foo.c  # remove foo.c from the index
git update-index foo.c           # add changes in foo.c to the index

You can collect changes that you plan to commit one by one with that 
command.  If you decide you no longer want to commit them "git reset" 
will reset the index back to HEAD without changing the checked out files 
themselves.

You can compare the index to HEAD with the following command, as I 
mentioned:

git diff-index -p HEAD

Mike



More information about the wine-devel mailing list