git – 反向对工作副本应用提交

为了调查之前的提交引入的效果,我想反向将其应用到我的工作副本,并绕过代码.

我通过创建和应用补丁的工作流管理,但是想知道这是否可以更容易.

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还原或git rebase -i,因为这些将引入新的提交或更改历史记录:我只是希望d9fd2bb中引入的更改不会应用于我当前的工作副本.

git revert -n怎么样?

06000

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.

翻译自:https://stackoverflow.com/questions/16059771/reverse-apply-a-commit-to-working-copy

转载注明原文:git – 反向对工作副本应用提交