如何将本地分支重新建立到远程主服务器上 [英] How to rebase local branch onto remote master

查看:43
本文介绍了如何将本地分支重新建立到远程主服务器上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从远程存储库 remote_repo 的master分支中克隆了一个项目.我创建一个新分支,然后提交该分支.其他程序员将 remote_repo 推送到master分支.

I have a cloned project from a master branch from remote repository remote_repo. I create a new branch and I commit to that branch. Other programmers pushed to remote_repo to the master branch.

我现在需要将本地分支 RB 重新建立到 remote_repo master 分支上.

I need now to rebase my local branch RB onto remote_repo's master branch.

如何执行此操作?要在终端上键入什么命令?

How to do this? What commands to type to a terminal?

推荐答案

首先从上游存储库中获取新的master,然后在此基础上重新构建您的工作分支:

First fetch the new master from the upstream repository, then rebase your work branch on that:

git fetch origin            # Updates origin/master
git rebase origin/master    # Rebases current branch onto origin/master

更新:请参阅 Paul Draper的答案,以获取更简洁的方法-最新的Git版本提供了一种更简单的方法来完成上述两个命令的作用.

Update: Please see Paul Draper's answer for a more concise way to do the same - recent Git versions provide a simpler way to do the equivalent of the above two commands.

这篇关于如何将本地分支重新建立到远程主服务器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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