[英]Revert a merged pull request from master branch
I have accidentally merged
pull request into master
branch from my feature branch, which i should not have.我不小心
merged
拉取请求从我的功能分支合并到master
分支,这是我不应该的。 I am using gogs
.我正在使用
gogs
。 I cannot use revert button as there is not any functionality available.我无法使用还原按钮,因为没有任何功能可用。 How can i revert back the master to the position before my pull request so that master branch will be clean again.
在我的拉取请求之前,我如何将主分支恢复到 position 以便主分支将再次干净。
Also master branch is protected and commits should be pushed only through pull request.主分支也受到保护,提交只能通过拉取请求推送。 So
git push -f
is not working for me.所以
git push -f
对我不起作用。
I have read other questions but they were about a specific incidents.我读过其他问题,但它们是关于特定事件的。 I am not sure how can i achieve this.
我不知道我怎么能做到这一点。
If you have not added any other commit after the wrong merge I suggest you tu rely on the command line as follow:如果您在错误合并后没有添加任何其他提交,我建议您依赖命令行,如下所示:
git checkout master
git pull
git log --oneline --graph --decorate # Write down the hash of the last good commit
git reset --hard {{last-good-commit-hash}}
# Review your commits, and if it all right...
git push --force # Rewrite branch history, be carefully!!!
I have had the same problem before.我以前也遇到过同样的问题。 Going to the commit you want to revert to and hitting the revert button in Gogs is what you are supposed to do.
转到您想要恢复的提交并点击 Gogs 中的恢复按钮是您应该做的。
If that doesn't work: Every commit with Git has a commit hash connected to it.如果这不起作用:每个带有 Git 的提交都有一个提交 hash 连接到它。 This should be listed in the history of commits on the Gogs page.
这应该列在 Gogs 页面上的提交历史中。 There should be a button to easily copy any hash, so you don't have to type it out.
应该有一个按钮可以轻松复制任何 hash,因此您不必输入它。 If you can use a command line console, you can use "git revert [code]" where code is the commit hash linked to the earlier commit.
如果您可以使用命令行控制台,则可以使用“git revert [code]”,其中代码是链接到先前提交的提交 hash。 After that, "git push".
之后,“git push”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.