通常,要放弃对文件的更改,您可以执行以下操作:
git checkout -- <file>
如果我要放弃的更改是删除文件怎么办?上面的行会报错:
error: pathspec '<file>' did not match any file(s) known to git.
什么命令将恢复该单个文件而不撤消其他更改?
奖励积分:另外,如果我想放弃的更改是adding一份文件?我也想知道如何取消该更改。
假设您想要撤消以下效果git rm <file>
or rm <file>
其次是git add -A
或类似的东西:
# this restores the file status in the index
git reset -- <file>
# then check out a copy from the index
git checkout -- <file>
To undo git add <file>
,假设您尚未提交,上面的第一行就足够了。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)