2014-05-23 116 views
0

当在混帐修改了某些文件,使用git status,出来了以下消息:“git checkout”和“git checkout - ”有什么区别?

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撤消我的编辑,如建议。

我发现无论如何,从collegue,那git checkout script.php似乎实现相同的结果。

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

请提供至少一个链接到一些文件,证明你所说的。谢谢!

+1

另请参阅[什么是“ - ”(双破折号)是什么意思? (也称为“裸露双破折号”)](http://unix.stackexchange.com/q/11376/8132)。 –

回答

6

如果您有标签或分支名称为script.php,则git checkout script.php将签出该标签或分支,而git checkout -- script.php将签出当前分支中的文件。

+0

它是有道理的......但你会提供一些支持你刚刚写的东西的链接吗?为了接受你的答案,我想确保没有别的。 – clami219

+0

@ clami219这里你去:http://stackoverflow.com/a/1192194/6309 – VonC

+0

好工作!谢谢! – clami219

相关问题