我目前在工作目录中有三个已修改的文件.但是我希望其中一个重置为HEAD状态.
在SVN我会使用svn revert <filename>(svn update <filename>如果需要的话后跟),但在git我应该使用git reset --hard.但是,此命令无法在单个文件上运行.
有没有办法在git中丢弃单个文件更改并用新的HEAD副本覆盖它?
这个git命令中文件名之前的双破折号是什么意思?
git checkout --ours -- path/to/file.txt
git checkout --theirs -- path/to/file.txt
Run Code Online (Sandbox Code Playgroud)
这是强制性的吗?它等同于
git checkout --ours path/to/file.txt
git checkout --theirs path/to/file.txt
Run Code Online (Sandbox Code Playgroud) 在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
Run Code Online (Sandbox Code Playgroud)
因此,我通常会git checkout -- script.php按照建议撤消我的修改.
无论如何,我从一位同事身上发现,这git checkout script.php似乎可以达到同样的效果.
所以,我的问题是:是git checkout -- script.php和git checkout script.php同义词,还是没有?
请至少提供一些证明您所说内容的文档的链接.谢谢!