0
這裏是git checkout treeish -- file
做:爲什麼git checkout修改索引而沒有記錄下來呢?
$ git init foo
$ cd foo/
$ echo aaaa > file.txt
$ git add file.txt
$ git commit -m 'commit aaaa'
$ git checkout -b bbbb
$ echo bbbb > file.txt
$ git add file.txt
$ git commit -m 'commit bbbb'
$ git checkout master
$ git checkout bbbb -- file.txt
$ cat file.txt
bbbb
$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: file.txt
注意file.txt
不僅被修改,以包含bbbb
,但這種變化也被添加到索引。
然而,該男子頁指出:
DESCRIPTION
Updates files in the working tree to match the version in the index
or the specified tree. If no paths are given, git checkout will
also update HEAD to set the specified branch as the current branch.
...
git checkout [-p|--patch] [<tree-ish>] [--] <pathspec>...
When <paths> or --patch are given, git checkout does not switch
branches. It updates the named paths in the working tree from
the index file or from a named <tree-ish> (most often a commit).
In this case, the -b and --track options are meaningless and
giving either of them results in an error. The <tree-ish> argument
can be used to specify a specific tree-ish (i.e. commit, tag or
tree) to update the index for the given paths before updating
the working tree.
只有「工作樹」的手冊頁會談,並指出任何關於更新索引。
我不明白不一致。
可執行文件或手冊頁是不正確的? ...或者是否有一些我缺乏的假想的魔法混帳知識?
嗯..看起來像是假的重載然後,即,(a)指定什麼文件結帳和(b)告訴git也更新索引。我想要(a)但不是(b)... –
Archie
如果您使用'git reset'跟蹤checkout命令,那麼索引中的文件將與repo(在您當前的HEAD)匹配,並且工作目錄仍然會包含您簽出的文件。 –