给定一个已经使用commit提交,然后使用revert恢复的更改,那么撤消该恢复的最佳方法是什么?
理想情况下,这应该通过一个新的提交来完成,这样就不会重写历史。
给定一个已经使用commit提交,然后使用revert恢复的更改,那么撤消该恢复的最佳方法是什么?
理想情况下,这应该通过一个新的提交来完成,这样就不会重写历史。
当前回答
或者你可以用git checkout -b <new-branch> and git cherry-pick <commit> the before to the and git rebase to drop revert commit。像以前一样发送拉请求。
其他回答
要返回在提交后恢复的非暂存和暂存更改:
git reset HEAD@{1}
恢复所有未执行的删除操作:
git ls-files -d | xargs git checkout --
在最初意外删除所有文件的恐慌之后,我使用以下方法来取回我的数据
git reset HEAD@{1}
git fsck --lost-found
git show
git revert <sha that deleted the files>
或者你可以用git checkout -b <new-branch> and git cherry-pick <commit> the before to the and git rebase to drop revert commit。像以前一样发送拉请求。
我有一个问题,有人做了一个恢复到主到我的分支,但我需要能够合并它,但问题是,恢复包括我所有的提交。 让我们看看这种情况,我们从M1创建了我们的特征分支,我们在M3中合并了我们的特征分支,并在RM3中恢复它
M1 -> M2 -> M3 -> M4- > RM3 -> M5
\. /
F1->F2 -
如何使F2能够合并到M5?
git checkout master
git checkout -b brach-before-revert
git reset --hard M4
git checkout master
git checkout -b new-feature-branch
git reset --hard M1
git merge --squash brach-before-revert
在我的例子中,我需要在恢复后提交更改,然后才能在没有失败的情况下选择原始提交。
git commit -m "Make changes (original commit)."
git revert <original commit hash>
git commit -m "Revert original commit."
git cherry-pick <original commit hash>