如何从一个远程分支到另一个远程分支
我正在从事一个项目,然后从A Release_branch 剪下一个分支让我们叫我的分支 branch_a 。我的同事还从同一版本分支上切了另一个分支,让我们称其为 branch_b 。我们正在处理相同的文件和部分,因此,以避免我想对我 branch_b 进行更改为我的 branch_a 的任何合并冲突。 branch_b 的更改已经合并到该 Release_branch 中,我们从中又切成了分支。
有人可以告诉我该怎么办吗?我尝试了拉拉,但它不起作用。另外,我切换到 Release_branch 并进行了拉动,并且在那里进行了更改,但是一旦我切换到我的 branch_a ,更改就消失了。请帮忙。
I'm working on a project and I cut a branch from a release_branch let's call my branch branch_A. My colleague also had cut another branch from same release branch and lets call that branch_B. We are working on the same file and section hence to avoid any merge conflicts I wanted to take changes from branch_B to my branch_A. Changes of branch_B has already been merged into that release_branch from which we had cut our branches earlier.
Can somebody tell what should I do? I've tried pull but it didn't work. Also I switched to the release_branch and took pull and changes were there but as soon as I switched to my branch_A the changes were gone. Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,请确保您对
branch_a
进行所有更改,并且如果您担心在过程的一部分中丢失工作,请在branch_a
(例如branch_a
)创建一个新分支。代码> branch_a_old )。由于您最终将合并回
Release_branch
,因此您可以使用以下方法之一:Branch_a
,如果还没有,请从branch_a
使用git Pull -no-rebase remote_name/repares_branch
。这将创建合并提交,合并最新的Release_branch
,包括branch_b
进行的更改。如果有任何冲突,您将必须解决它们并执行完成合并的承诺。branch_a
,fetchremote_name/repares_branch
,然后合并remote_name/reparter_branch
inbranch_a
。这基本上与方法1相同,但分为两个步骤。branch_a
,fetchremote_name/repares_branch
,然后rebasebranch_a
使用remoce_name/reasion_branch
作为上游分支。另外,您可以使用git Pull - Rebase Remote_name/Release_branch
将获取并折叠为一个步骤。方法1和2将保持合并作为历史记录的一部分,方法3将更新分支中的所有提交,以便您的分支以
Release_branch
的最新提交开始。方法1和2通常更容易,尽管这是有争议的,但是方法3将提供更清洁的历史记录。如果您确实使用方法1或2,则可以随时执行壁球以清理历史记录。
First, make sure that you commit all changes to your
branch_A
and if you are concerned about losing your work as part of the process, create a new branch atbranch_A
(e.g.branch_A_old
).Since you will eventually be merging back to
release_branch
, you can use one of the following approaches:branch_A
, if not already, then pull fromremote_name/release_branch
intobranch_A
usinggit pull --no-rebase remote_name/release_branch
. This will create a merge commit, merging the latestrelease_branch
, including changes made bybranch_B
into your branch. If there are any conflicts, you will have to resolve them and perform a commit to complete the merge.branch_A
, fetchremote_name/release_branch
, then mergeremote_name/release_branch
intobranch_A
. This is basically the same as method 1, but broken into two steps.branch_A
, fetchremote_name/release_branch
, then rebasebranch_A
usingremote_name/release_branch
as the upstream branch. Alternatively, you can use usegit pull --rebase remote_name/release_branch
to combine the fetch and rebase into one step.Methods 1 and 2 will keep the merge as part of the history and method 3 will update all of the commits in your branch so that your branch begins at the latest commit of
release_branch
.Methods 1 and 2 are usually easier, although this is debatable, but method 3 will provide a cleaner history. If you do use method 1 or 2, you can always perform a squash later to clean up the history.