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

Re: checkout extra files

From
ABAngelo Borsotti <angelo.borsotti@gmail.com>
Date
Sep 4, 2012, 07:15 UTC
Message-ID
<CAB9Jk9BbOJgVNepFittD5fVkFLY24Tf10PVg3MD6E1M3hMyNsQ@mail.gmail.com>
In-Reply-To
<7vd322ebsz.fsf@alter.siamese.dyndns.org>
Hi all,
consider this example:
$ mkdir gittest
$ cd gittest
$ git init
Initialized empty Git repository in d:/gittest/.git/
$ touch f1
$ git add f1
$ git commit commit -m "first commit"
[master (root-commit) e6f935e] first commit
 0 files changed
 create mode 100644 f1
$ touch f2
$ git checkout e6f9 -- *
error: pathspec 'f2' did not match any file(s) known to git.

Note the error. It is clear that the set of file names that git checkout is taking is the union of the ones that match the specified path ('*') in the work directory (gittest) with the ones that match the path in the specified commit (e6f9). I am not questioning this behavior, but the documentation, which does not describe it:

   "It updates the named paths in the working tree from the index file or
   from a named <tree-ish> ..."
There are two ways to read this sentence:
    1.  "named paths" referred to working tree, i.e. the files whose
names match the
          paths among all the ones present in the working tree
    2.  "named paths" referred to the index or tree-ish, i.e. the
files whose names match
          paths among oll the ones present in the index or tree-ish

In both cases, nothing tells the user that the matching of the paths is done over the union of the set of file names of the working tree + ndex or tree-ish. Indeed, the first time I have seen the error above I got quite confused because I thought that the checkout would restore the working directory as it was at the time I made the commit, without bothering about extra files that the directory contained at the moment (and note that f2 is not even a tracked one). This behavior is a bit strange, but if it is a hundred percent clearly documented I can live with it.

I think that knowing precisely what files are involved in this command is essential for the user.

-Angelo
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 36 in “checkout extra files”
  1. Angelo BorsottiSep 3, 2012
  2. Carlos Martín NietoSep 3, 2012
  3. Nguyen Thai Ngoc DuySep 3, 2012
  4. Junio C HamanoSep 3, 2012
  5. Nguyen Thai Ngoc DuySep 4, 2012
  6. Junio C HamanoSep 4, 2012
  7. Angelo BorsottiSep 4, 2012
  8. Junio C HamanoSep 4, 2012
  9. Junio C HamanoSep 4, 2012
  10. Junio C HamanoSep 4, 2012
  11. Junio C HamanoSep 7, 2012
  12. Philip OakleySep 8, 2012
  13. Junio C HamanoSep 9, 2012
  14. Matthieu MoySep 9, 2012
  15. Junio C HamanoSep 9, 2012
  16. Philip OakleySep 9, 2012
  17. Jeff KingSep 10, 2012
  18. Junio C HamanoSep 10, 2012
  19. Jeff KingSep 10, 2012
  20. Junio C HamanoSep 10, 2012
  21. 1/2 gitcli: formatting fixJunio C Hamano, Sep 10, 2012
  22. 2/2 gitcli: contrast wildcard given to shell and to gitJunio C Hamano, Sep 10, 2012
  23. Jeff KingSep 10, 2012
  24. Junio C HamanoSep 10, 2012
  25. Nguyen Thai Ngoc DuySep 4, 2012
  26. Junio C HamanoSep 4, 2012
  27. Carlos Martín NietoSep 3, 2012
  28. Carlos Martín NietoSep 4, 2012
  29. Angelo BorsottiSep 4, 2012
  30. Junio C HamanoSep 4, 2012
  31. Angelo BorsottiSep 4, 2012
  32. Junio C HamanoSep 4, 2012
  33. Philip OakleySep 4, 2012
  34. Junio C HamanoSep 4, 2012
  35. Junio C HamanoSep 8, 2012
  36. Junio C HamanoSep 10, 2012

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.