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

Re: [PATCH] Documentation/git-checkout: make doc. of checkout <tree-ish> clearer

From
CMChristoph Michelbach <michelbach94@gmail.com>
Date
Apr 18, 2017, 12:02 UTC
Message-ID
<1492516967.5720.32.camel@gmail.com>
In-Reply-To
<xmqqefwqims1.fsf@gitster.mtv.corp.google.com>
On Mon, 2017-04-17 at 17:26 -0700, Junio C Hamano wrote:
Show 27 quoted lines
> "Philip Oakley" <philipoakley@iee.org> writes:
> 
> > 
> > I'd guess that the misunderstanding is that you maybe thought that
> > the
> > whole directory would be reset to it's old state and the files b and
> > c
> > deleted, rather than just the named files present in that old commit
> > being extracted. If we'd created and added a file d just before the
> > checkout, what should have happened to d, and why?
> It probably is a bit unfair to call it "misunderstanding".  I've had
> this entry in the "Leftover Bits" list for quite some time:
> 
>     git checkout $commit -- somedir may want to remove somedir/file
> that
>     is not in $commit but is in the original index. Anybody who wants
> to
>     do this needs to consider ramifications and devise transition
> plans.
>     Cf. $gmane/234935
> 
> In the thread, this message:
> 
> https://public-inbox.org/git/xmqqeh8nxltc.fsf@gitster.dls.corp.google.
> com/
> 
> may be a good summary.

For clarification: I'm not saying that that's how the command should behave. I merely want the documentation to describe how the command actually behaves.

Of course, being able to reset a folder to a previous state would be great, too. I have needed that several times and what I ended up doing is to delete the folder and then do the checkout. This doesn't cause problems if there are no untracked files (as of the state one wants to restore; what's currently tracked is of course irrelevant) you still need in that folder. If that's the case, one must make sure to not delete those files.

I don't know whether there's an easier/better way, though. That's merely what I did.

Having the *option* to reset an entire folder rather than the files in it would be great.

-- Christoph

Previous: Junio C HamanoNext: Philip Oakley
Message 10 of 23 in “Documentation/git-checkout: make doc. of checkout <tree-ish> clearer”
  1. Documentation/git-checkout: make doc. of checkout <tree-ish> clearerChristoph Michelbach, Apr 15, 2017
  2. Philip OakleyApr 15, 2017
  3. Christoph MichelbachApr 16, 2017
  4. Philip OakleyApr 16, 2017
  5. Christoph MichelbachApr 16, 2017
  6. Philip OakleyApr 16, 2017
  7. Christoph MichelbachApr 16, 2017
  8. Philip OakleyApr 17, 2017
  9. Junio C HamanoApr 18, 2017
  10. Christoph MichelbachApr 18, 2017
  11. Philip OakleyApr 19, 2017
  12. Philip OakleyApr 17, 2017
  13. Junio C HamanoApr 18, 2017
  14. Christoph MichelbachApr 18, 2017
  15. Junio C HamanoApr 19, 2017
  16. Christoph MichelbachApr 22, 2017
  17. Junio C HamanoApr 24, 2017
  18. Christoph MichelbachApr 24, 2017
  19. Christoph MichelbachApr 24, 2017
  20. Junio C HamanoApr 25, 2017
  21. Christoph MichelbachApr 25, 2017
  22. Philip OakleyApr 19, 2017
  23. Christoph MichelbachApr 18, 2017

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.