我正在使用azure管道,我需要在我的主分支中执行一个代码回滚,(主分支中的代码来自不同的版本,例如release/1.0.0、release/1.0.1并标记)。
根据我的搜索结果,我得到了以下信息:
1. git checkout master
2. git reset --hard <tagname>
3. git push --force origin master有人能帮忙吗,这是在主分支中进行回滚的最佳方法吗?或者不是。此外,在本例中,代码将被前面的标记代码覆盖,我们是否需要再次标记分支。
发布于 2022-09-08 07:46:53
听起来是我迈出的一大步..。你知道这样改写历史的后果吗?如果你不这样做,那么很可能这不是正确的道路。通常,如果要将代码带回到版本中的代码,则应在当前历史记录之后创建一个新的修订版,该版本将代码调回。
在你的例子中,你应该做如下的事情:
git checkout --detach <tagname>
git reset --soft master # set the HEAD pointer where master is
# content of files in working tree and index are like in <tagname>
git commit -m "Take code back to <tagname>"
# at this point this is a revision with no branch
# check history with git log to see if this is what you would like to have in master
# if you do like it:
git branch -f master # set master branch over here
git checkout master
git push那应该管用。
https://stackoverflow.com/questions/73645374
复制相似问题