如何避免Foxtrot在git中合并 [英] how to avoid foxtrot merge in git

查看:177
本文介绍了如何避免Foxtrot在git中合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们最近陷入无法推送代码的情况,并收到错误消息,提示"Control Freak ... FoxTrot Merge"

We recently got into a situation wherein we could not push the code and got error message indicating "Control Freak... FoxTrot Merge"

基本上,这是我们的源代码树-

Basically, this is our source tree-

分支-A(这是来自起源/母版的子代,而不是来自起源/母版的子代) 从A创建了另一个分支B-对其进行处理 从C创建了另一个分支

Branch - A (this is a child of origin/develop which was off origin/master) Created Another branch B from A - Work on it Created another branch from C

在几次提交之后的某个时刻,它不会让我们将任何提交推送到C 并抱怨FoxTrot合并. 我们检查了bitbucket(企业)是否有一个钩子将其挡住.

At some point after few commits, it won't let us push any commits to C and complained about FoxTrot merge. We checked that bitbucket (enterprise) had a hook which blocks this.

我们通过创建另一个分支D绕过了这一步(因为我们确实必须进行更改).

We bypassed this (Since we really had to push the changes) by creating another branch D.

我们不知道我们如何在这种情况下降落. 将来如何避免这种情况?

We don't know how we landed in this situation. How can we avoid this in future?

推荐答案

我将其作为重复项关闭,但是重复"问题本身只是定义狐步舞合并而没有解释为什么会发生.

I'm going to close this as a duplicate, but the "duplicate" question itself just defines foxtrot merges without explaining why they happen.

之所以会发生,是因为git pull表示git fetch && git merge,第二个git merge 是狐步合并".它将您的工作视为主要分支,而将 else的工作(在您开始工作后在master 上完成)作为次要分支,可能不是主分支.挂钩的目的是防止人们使用master并像这样使用git pull.

They happen because git pull means git fetch && git merge and that second git merge is a "foxtrot merge". It treats your work as the main branch, and someone else's work, done on master after you started on your work, as a secondary, probably-not-master branch. The goal of the hook is to prevent people from working on master and using git pull like this.

为避免发生这种情况,您可以使用以下简单规则(也许有点简单,但它可以起作用):永远不要自己动手做任何事情.

To avoid having this sort of thing happen, you can use this simple rule (perhaps a bit too simple but it works): never do any work on master yourself.

也就是说,在之后:

git clone <url>
cd <clone>

您将开始工作:

git checkout -b feature/tall

使用名为tall的新功能.您好,爱丽丝-可能不是您的真实姓名,但是在此示例中,我有三个人在做事情,因此我为您指定了名称"A" –使用您自己的feature/tall完成所有工作,而鲍勃和无论功能名称是什么,Carol都会在自己的功能分支上完成所有工作.

to work on the new feature named tall. You, Alice—well, that's probably not your actual name, but I have three people doing things in this example, so I've assigned you the name "A"–do all your work on your own feature/tall, while Bob and Carol do all their work on their own feature branches, whatever their features' names are.

然后,当您准备好东西时,您就可以这样做:

Then when your stuff is ready you do:

git checkout master && git fetch && git merge

或者,如果您喜欢git pull(我不喜欢):

or, if you like git pull (I don't):

git checkout master && git pull

您现在准备合并功能:

git merge feature/tall

并且合并完成后(如有必要,在解决了所有合并冲突之后),您可以再次推送:

and when the merge is complete—after resolving any merge conflicts if necessary—you can push again:

git push

,您的工作将显示为非狐步合并".成功合并并推送您的作品后,您可以删除功能分支.同时,鲍勃(Bob)和卡罗尔(Carol)可以继续研究他们的功能,或者,如果他们在完成之前完成了他们的合并,那么他们的合并将放在他们的合并之上.

and your work appears as a non-"foxtrot merge". Once your work is successfully merged and pushed you can delete your feature-branch. Meanwhile Bob and Carol can keep working on their features, or, if they finished before you did, your merge merges atop their merges.

这篇关于如何避免Foxtrot在git中合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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