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

understanding index

From
NSNicolas Sebrecht <nicolas.s-dev@laposte.net>
Date
Jan 31, 2009, 11:10 UTC
Message-ID
<20090131111011.GA29748@ultras>
Hey list.

I'm having some understanding trouble with git index. As I understand, 'git rm --cached' is not strictly the opposite of 'git add'. It's a little embarrassing in this particular case : what if you want to commit and did a wrong 'git add -u' command ?

Here's a minimalist sample :

% ls foo bar

[ hack, hack, hack on both files ]
% git status
[...]
	modified: foo
	modified: bar
[...]
% git add -u foo bar

[ optional hack on foo ] [ damn, you realize you don't want to commit changes on foo at all ]

% git rm --cached foo
% git status
[...]
	deleted: foo
	modified: bar
[...]

If committed as is, foo will be marked as deleted (in 'git log --name-status' at least, which is not wanted).

How to retrieve the state before the wrong 'git add -u' command _and_ keep the working tree as well (including last hacks) ? Is there any command which is the exact opposite of 'git add -u' ?

Cheers,
-- 
Nicolas Sebrecht
Next: Santi Béjar
Message 1 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.