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

Re: (beginner) git rm

From
ZZabre <427@free.fr>
Date
Jan 28, 2009, 12:00 UTC
Message-ID
<1233144045221-2231849.post@n2.nabble.com>
In-Reply-To
<49804385.908@dbservice.com>
Tomas Carnecky wrote:
> 
> Do you mean 'undelete' a file? git checkout d.txt - That restores the 
> file in the working tree and resets the index just for that file.
> 

Hi Tom, (thank you for your interest in my newbie problems)

yes that's what I mean : 'undelete' a file, after a "git rm d.txt". But I did not manage to apply your solution succesfully : $ git rm d.txt $ ls a.txt b.txt c.txt $ git status # On branch new # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # deleted: d.txt # $ git checkout d.txt error: pathspec 'mamma.txt' did not match any file(s) known to git. Did you forget to 'git add'?

So it did not work but I've just noticed that unstage tip given by the status command, and I did the following (which worked)

$ git reset HEAD d.txt d.txt: needs update $ ls a.txt b.txt c.txt $ git checkout d.txt $ ls a.txt b.txt c.txt d.txt

Reading the git reset help file gives me the feeling I should use this with caution... It looks like you can somehow modify the change history. Anyway these two commands helped me change the index the way I wanted. Please tell me if this might somehow go wrong in another situation.

-- 
View this message in context: http://n2.nabble.com/%28beginner%29-git-rm-tp2231416p2231849.html
Sent from the git mailing list archive at Nabble.com.
Previous: Tomas CarneckyNext: Tomas Carnecky
Message 5 of 16 in “(beginner) git rm”
  1. ZabreJan 28, 2009
  2. Peter KreftingJan 28, 2009
  3. ZabreJan 28, 2009
  4. Tomas CarneckyJan 28, 2009
  5. ZabreJan 28, 2009
  6. Tomas CarneckyJan 28, 2009
  7. Theodore TsoJan 28, 2009
  8. ZabreJan 28, 2009
  9. ZabreJan 28, 2009
  10. Björn SteinbrinkJan 28, 2009
  11. ZabreJan 28, 2009
  12. ZabreJan 28, 2009
  13. Junio C HamanoJan 28, 2009
  14. Björn SteinbrinkJan 28, 2009
  15. Junio C HamanoJan 28, 2009
  16. Björn SteinbrinkJan 29, 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.