git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: understanding index

From
Björn Steinbrink <b.steinbrink@gmx.de>
Date
Jan 31, 2009, 21:18 UTC
Message-ID
<20090131211800.GA30645@atjola.homenet>
In-Reply-To
<20090131201920.GC29748@ultras>
On 2009.01.31 21:19:20 +0100, Nicolas Sebrecht wrote:
Show 22 quoted lines
> 
> On Sat, Jan 31, 2009 at 01:09:49PM +0100, Santi Béjar wrote:
> 
> > You omitted the help message of git status, where it says how to unstage:
> > # Changes to be committed:
> > #   (use "git reset HEAD <file>..." to unstage)
> > 
> > So to not commit foo at all:
> > 
> > git reset HEAD foo
> 
> Thanks. I didn't omitted the help message of git status. The "unstage"
> action is what I was looking for but I was wrongly presuming (and I've
> read git docs !) that 'HEAD' is a kind of shortcut to the last commit of
> the current branch (not to the last state of the working tree).
> 
> Working on branch master for example, we have in .git/HEAD :
> ref: refs/heads/master
> And in .git/refs/heads/master, the hash of the last commit of branch
> master.
> 
> I'm missing something here. But what ?

You're missing the fact that you want to reset the index entry to the state from HEAD. The working tree state is the modified one, and you get that into the index using "git add". But you want the index entry to be back at the state from HEAD. So HEAD is what you need to pass to reset (well, actually, you can skip "HEAD" there, it's the default).

Björn
Previous: Nicolas Sebrecht
Message 7 of 7 in “understanding index”
  1. Nicolas SebrechtJan 31, 2009
  2. Santi BéjarJan 31, 2009
  3. Alex RiesenJan 31, 2009
  4. Nicolas SebrechtJan 31, 2009
  5. Santi BéjarJan 31, 2009
  6. Nicolas SebrechtJan 31, 2009
  7. Björn SteinbrinkJan 31, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.