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怎么样?


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 – 反向对工作副本应用提交