git - 反向将提交应用于工作副本

标签 git revert

为了研究之前的提交所带来的影响,我想将其反向应用到我的工作副本并修改代码。

我通过围绕创建和应用补丁的工作流程进行管理,但想知道这是否可以更轻松地完成。

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 revertgit 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/

相关文章:

git - 将分支从 Team Foundation Service pull 到 Visual Studio 2012

git - 即使在 git add 之后,更改也不会提交

git - "git checkout - ..."中的 -(单破折号)是什么意思?

git - 如何获取以前版本的 sha 哈希值,git

magento - SVN/TortoiseSVN 慢得要命

git - 使用 Github 网络界面或桌面应用程序将 Gist 重置或恢复到较旧的提交状态

git - 跟踪分支历史

git - 为什么顺序是 git add --all、git commit、然后 git push 跳过文件?

git - 有人可以解释 'git revert ...'

mercurial - hg revert 和 hg backout 之间有什么区别?