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

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

问题描述

我不小心将一个功能分支推送到远程主服务器.现在我想将 master 恢复到之前的提交.当我选择 'Revert current branch to this commit' 时,只有本地分支被恢复,并且因为远程 master 领先 55(意外推送)我无法将刚刚恢复的本地 master 推送到远程.

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 上查看此问题时,我发现许多人使用命令行强制推送.但由于我使用的是 Source Tree,我想想出一种实际使用 Source Tree 的方法.

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天全站免登陆