我如何“取消还原"恢复的 Git 提交? [英] How do I "un-revert" a reverted Git commit?
本文介绍了我如何“取消还原"恢复的 Git 提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
鉴于使用 commit
提交的更改,然后使用 revert
还原,然后撤消该还原的最佳方法是什么?
Given a change that has been committed using commit
, and then reverted using revert
, what is the best way to then undo that revert?
理想情况下,这应该通过新的提交来完成,以免重写历史.
Ideally, this should be done with a new commit, so as to not re-write history.
推荐答案
如果你还没有推送那个改动,git reset --hard HEAD^
If you haven't pushed that change yet, git reset --hard HEAD^
否则,还原还原完全没问题.
Otherwise, reverting the revert is perfectly fine.
另一种方法是 git checkout HEAD^^ -- .
然后 git add -A &&git commit
.
Another way is to git checkout HEAD^^ -- .
and then git add -A && git commit
.
这篇关于我如何“取消还原"恢复的 Git 提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文