问题:
I currently have three modified files in my working directory. 我目前在工作目录中有三个修改过的文件。 However I want one of them to be reset to the HEAD status. 但是我希望其中一个重置为HEAD状态。
In SVN I'd use svn revert <filename>
(followed by svn update <filename>
if needed) but in git I should use git reset --hard
. 在SVN中,我使用svn revert <filename>
(如果需要,然后是svn update <filename>
)但是在git中我应该使用git reset --hard
。 However this command cannot operate on a single file. 但是,此命令无法在单个文件上运行。
Is there any way in git to discard a single file changes and overwrite it with a fresh HEAD copy? 有没有办法在git中丢弃单个文件更改并用新的HEAD副本覆盖它?
解决方案:
参考一: https://stackoom.com/question/TzKY/单个文件的硬重置参考二: https://oldbug.net/q/TzKY/Hard-reset-of-a-single-file
来源:oschina
链接:https://my.oschina.net/u/4428122/blog/4321640