为了研究之前的提交所带来的影响,我想将其反向应用到我的工作副本并修改代码。
我通过围绕创建和应用补丁的工作流程进行管理,但想知道这是否可以更轻松地完成。
git checkout -b "tmp-fiddle"
git diff -R -p d9fd2bb^ d9fd2bb > patch_to_examine.patch
# Manually edit the patch a little
git apply patch_to_examine.patch
请注意,我没有查看 git revert
或 git rebase -i
,因为它们会引入新的提交或更改历史记录:我只想引入更改在 d9fd2bb
中取消应用于我当前的工作副本。
最佳答案
git revert -n
怎么样? ?
-n --no-commit
Usually the command automatically creates some commits with commit log messages stating which commits were reverted. This flag applies the changes necessary to revert the named commits to your working tree and the index, but does not make the commits. In addition, when this option is used, your index does not have to match the HEAD commit. The revert is done against the beginning state of your index.
This is useful when reverting more than one commits' effect to your index in a row.
关于git - 反向将提交应用于工作副本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16059771/