使用sourcetree将推送恢复到远程 [英] Reverting push to remote with sourcetree

查看:328
本文介绍了使用sourcetree将推送恢复到远程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不小心将功能分支推送到了远程主机.现在,我想将母版还原到上一个提交.当我选择将当前分支还原为该提交"时,仅还原本地分支,并且由于远程主节点在55前面(偶然按下),因此我无法将刚刚还原的本地主节点推送到远程.

I accidently pushed a feature branch to the remote master. Now I want to revert the master to the previous commit. When I select 'Revert current branch to this commit' only the local branch is reverted, and because the remote master is 55 ahead (accidental push) I cannot push the just reverted local master to the remote.

在SO和Google上研究此问题时,我发现许多人通过命令行使用强制推送.但是,由于我正在使用源代码树",因此我想提出一种实际使用源代码树"的方法.

When looking into this issue on SO and Google, I found that many people use force push using the command line. But since I'm using Source Tree I'd like to come up with a way that actually uses Source Tree.

我还找到了rebase选项,但是似乎找不到分步教程.

I also found the rebase option, but I can't seem to find a step-by-step tutorial..

有什么想法吗?

推荐答案

当您推送提交时,还原提交的最安全方法(而不是使用-f强制推送)是使用revert函数,因此新的提交将在您先前的提交之上创建.

When you push a commit, the safest way to revert it (rather than forcing the push with -f) is to use the revert function, so a new commit is created on top of your previous commit.

可以使用Sourcetree进行此操作,右键单击要还原的提交,然后选择反向提交...".

This is possible to do using Sourcetree, right clicking in the commit that you want to revert, and selecting "Reverse commit...".

您需要以相反的顺序对每个要还原的提交执行此操作.

You would need to do this for each commit you want to revert, in reverse order.

这篇关于使用sourcetree将推送恢复到远程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆