在我跟踪 svn 存储库的 git 存储库中,我对单个文件进行了多次编辑。
现在我想恢复这些更改(如 svn revert),但只是文件的一部分。
我希望能够查看文件上的差异,丢弃(恢复)我不想要的更改并保留我想要的更改。
the
git add -i
命令似乎可以选择执行此操作,但我还不想上演此操作。
我相信您可以通过以下方式最简单地做到这一点:
git checkout -p <optional filename(s)>
从联机帮助页:
−p, −−patch
Interactively select hunks in the difference between the <tree−ish>
(or the index, if unspecified) and the working tree. The chosen
hunks are then applied in reverse to the working tree (and if a
<tree−ish> was specified, the index).
This means that you can use git checkout −p to selectively discard
edits from your current working tree.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)