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

Re: Restore a single file in the index back to HEAD

From
APAndy Parkins <andyparkins@gmail.com>
Date
Oct 27, 2006, 07:27 UTC
Message-ID
<200610270827.17659.andyparkins@gmail.com>
In-Reply-To
<81b0412b0610260842x52413570k3971bcdc54b3ccb5@mail.gmail.com>
On Thursday 2006 October 26 16:42, Alex Riesen wrote:
Thanks for your suggestion.
> Use "git checkout HEAD oops/file1"
This returned:

"git checkout: updating paths is incompatible with switching branches/forcing Did you intend to checkout 'oops/file1' which can not be resolved as commit?"

I'm not sure that checkout will do what I want anyway because it would overwrite the working directory copy of oops/file1. I want to keep the changes but reset the index to have oops/file1 from HEAD.

Maybe I need to say a little more about what I'm trying to do:

I converted a subversion repository to git. In that repository I maintained my own set of patches in one branch against an upstream branch; I'm now using git-cherry-pick to pull a subset of those patches onto a new branch against the upstream head. This is all working fine. The problem is that I've come across a patch that should rightly be two patches instead of one.

So, I cherry-pick a patch, which updates the working directory and index, leaving me with...

# On branch refs/heads/newmaster # Updated but not checked in: # (will commit) # # modified: oops/file1 # modified: good/file2 # modified: good/file3 # modified: good/file4

Instead, what I would like is

# On branch refs/heads/newmaster # Updated but not checked in: # (will commit) # # modified: good/file2 # modified: good/file3 # modified: good/file4 # # On branch refs/heads/newmaster # Changed but not updated: # (use git-update-index to mark for commit) # # modified: oops/file1

I've actually found a way around the problem. I do git-reset HEAD, which restores the index entirely but leaves the working directory. Then I git-update-index the good/* set. However, it led me to wonder what the inverse of git-update-index is.

Andy
-- 
Dr Andy Parkins, M Eng (hons), MIEE
Previous: Alex RiesenNext: Shawn Pearce
Message 3 of 31 in “Restore a single file in the index back to HEAD”
  1. Andy ParkinsOct 26, 2006
  2. Alex RiesenOct 26, 2006
  3. Andy ParkinsOct 27, 2006
  4. Shawn PearceOct 27, 2006
  5. Andy ParkinsOct 27, 2006
  6. Andreas EricssonOct 27, 2006
  7. Shawn PearceOct 27, 2006
  8. Alex RiesenOct 27, 2006
  9. Andreas EricssonOct 27, 2006
  10. Junio C HamanoOct 27, 2006
  11. Luben TuikovOct 27, 2006
  12. Nguyen Thai Ngoc DuyNov 1, 2006
  13. Junio C HamanoNov 1, 2006
  14. Junio C HamanoNov 1, 2006
  15. Nguyen Thai Ngoc DuyNov 1, 2006
  16. Jakub NarebskiNov 1, 2006
  17. Jakub NarebskiNov 1, 2006
  18. Andy ParkinsNov 1, 2006
  19. Junio C HamanoNov 1, 2006
  20. Andy ParkinsNov 1, 2006
  21. Junio C HamanoNov 1, 2006
  22. Andy ParkinsNov 1, 2006
  23. Junio C HamanoNov 1, 2006
  24. Andy ParkinsNov 1, 2006
  25. Junio C HamanoNov 1, 2006
  26. Andy ParkinsNov 1, 2006
  27. Junio C HamanoNov 1, 2006
  28. Andy ParkinsNov 2, 2006
  29. Robin RosenbergNov 1, 2006
  30. Salikh ZakirovNov 2, 2006
  31. Added description for inverting git-update-index using --index-infoAndy Parkins, Oct 27, 2006

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.