如何将本地分支重新建立到远程主服务器上 [英] How to rebase local branch onto remote master
问题描述
我从远程存储库 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屋!