checkout extra files
- From
- Angelo Borsotti <angelo.borsotti@gmail.com>
- Date
- Sep 3, 2012, 13:42 UTC
- Message-ID
- <CAB9Jk9BvQmFfTq3a+e-7t-66s06jLK4fWuZB+MJHrAtbznBvHw@mail.gmail.com>
Hello,
the man page of git checkout states:
git checkout [-p|--patch] [<tree-ish>] [--] <pathspec>...
It updates the named paths in the working tree from the index file or from a named <tree-ish> ...
This means that for each file denoted by pathspec, git tries to restore it from the tree-ish. However, it seems that git does more than this: it restores also files that are not denoted by pathspec. This sequence of commands shows it:
$ 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) 94d882a] first commit 0 files changed create mode 100644 f1 $ rm f1 $ git checkout 94d8 -- * $ ls f1
Note that the work directory is empty when the checkout is done, and that the checkout restores f1 in it, a file that is not denoted by the * pathspec. I guess that this is the intended behaviour, and that the man page should be updated to tell exactly what files git restores.
-Angelo Borsotti