在最后一次提交之后,我在工作副本中修改了一堆文件,但我想撤消对其中一个文件的更改,就像将其重置为与最近提交的状态相同。但是,我只想撤消单独一个文件的工作副本更改,而不是其它任何内容。我怎么做?
3 回答

LEATH
TA贡献1936条经验 获得超6个赞
您可以使用
git checkout -- file
您可以在没有--(如nimrodm建议)的情况下执行此操作,但如果文件名看起来像分支或标记(或其他修订标识符),则可能会混淆,因此使用--最佳。
您还可以查看文件的特定版本:
git checkout v1.2.3 -- file # tag v1.2.3
git checkout stable -- file # stable branch
git checkout origin/master -- file # upstream master
git checkout HEAD -- file # the version from the most recent commit
git checkout HEAD^ -- file # the version before the most recent commit

一只甜甜圈
TA贡献1836条经验 获得超5个赞
git checkout <commit> <filename>
我今天使用了这个,因为我意识到当我升级到drupal 6.10时,我的favicon已被覆盖了几次提交,所以我不得不把它取回来。
- 3 回答
- 0 关注
- 627 浏览
添加回答
举报
0/150
提交
取消