如何从一个远程分支到另一个远程分支

发布于 2025-01-26 15:48:58 字数 399 浏览 1 评论 0原文

我正在从事一个项目,然后从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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

彼岸花ソ最美的依靠 2025-02-02 15:48:59

首先,请确保您对branch_a进行所有更改,并且如果您担心在过程的一部分中丢失工作,请在branch_a(例如branch_a)创建一个新分支。代码> branch_a_old )。

由于您最终将合并回Release_branch,因此您可以使用以下方法之一:

  1. Checkout Branch_a,如果还没有,请从remote_name/Release_branch < /代码>进入branch_a使用git Pull -no-rebase remote_name/repares_branch。这将创建合并提交,合并最新的Release_branch,包括branch_b进行的更改。如果有任何冲突,您将必须解决它们并执行完成合并的承诺。
  2. 结帐branch_a,fetch remote_name/repares_branch,然后合并remote_name/reparter_branch in branch_a。这基本上与方法1相同,但分为两个步骤。
  3. 结帐branch_a,fetch remote_name/repares_branch,然后rebase branch_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 at branch_A (e.g. branch_A_old).

Since you will eventually be merging back to release_branch, you can use one of the following approaches:

  1. Checkout branch_A, if not already, then pull from remote_name/release_branch into branch_A using git pull --no-rebase remote_name/release_branch. This will create a merge commit, merging the latest release_branch, including changes made by branch_B into your branch. If there are any conflicts, you will have to resolve them and perform a commit to complete the merge.
  2. Checkout branch_A, fetch remote_name/release_branch, then merge remote_name/release_branch into branch_A. This is basically the same as method 1, but broken into two steps.
  3. Checkout branch_A, fetch remote_name/release_branch, then rebase branch_A using remote_name/release_branch as the upstream branch. Alternatively, you can use use git 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文