單個檔案的硬重置 - Hard reset of a single file

語言: CN / TW / HK

問題:

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 the changes to a single file and overwrite it with a fresh HEAD copy? Git 中有沒有辦法放棄對單個檔案的更改並用新的 HEAD 副本覆蓋它?


解決方案:

參考一: https://stackoom.com/question/TzKY
參考二: Hard reset of a single file
「其他文章」