" git checkout"之间的区别是什么?和" git checkout - "?

时间:2014-05-23 10:55:44

标签: git

在git下使用git status修改一些文件时,会出现以下消息:

On branch dev
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   script.php

所以我通常使用git checkout -- script.php撤消我的修改,如建议的那样。

无论如何,我从一位同事那里发现git checkout script.php似乎也能达到同样的效果。

所以,我的问题是:git checkout -- script.phpgit checkout script.php同义词是不是?

请至少提供一些证明您所说内容的文档的链接。谢谢!

1 个答案:

答案 0 :(得分:7)

如果你有一个名为script.php的标记或分支,那么git checkout script.php将签出该标记或分支,而git checkout -- script.php将签出当前分支中的文件。

相关问题