在另一个功能分支中启动一个功能分支

时间:2020-08-27 05:41:29

标签: git git-branch git-flow git-config

我创建(git flow feature start branch1)并发布(git flow feature publish branch1)基于develop的git flow功能分支。在它们之后,我将其标记为Pull Request,以便其他开发人员查看该分支中的更改。但是现在我想进一步工作,因此我基于git flow feature start branch2在等待branch1的地方创建一个新的功能分支(Pull Request)。但是在创建branch2之后,只有branch1中的文件被忽略(所有文件都与.gitignore中的条件匹配)。

当我检出branch1时,我看到整个词典包含所有文件,但是为什么不是在所有新创建的功能分支(branch2)中呢?所以我不能再工作了。

我找到了问题,但没有找到解决方法:

.git/config文件中,记录了我的branch2分支develop base ,而不是branch1:< / p>

[gitflow "branch.feature/branch1"]
        base = develop
[branch "feature/branch1"]
        remote = origin
        merge = refs/heads/feature/branch1
[gitflow "branch.feature/branch2"]
        base = develop

使用以下命令,我可以从branch1中的branch2移动所有文件,但是.git/config文件中的 base 不会更改为{{1} } ...:

branch1

使用此模板构建:git rebase --onto feature/branch1 develop feature/branch2

如何从git rebase --onto newBase oldBase feature/branch更改基本分支?只需将branch2中的 base-branch branch2更改为branch1

1 个答案:

答案 0 :(得分:0)

您可以在base中更改.git/config,但不能更改。

base的{​​{1}}也是branch2,因为这是您以后要合并到的分支(在develop已经合并之后)。

这也反映在branch1中,它不是从您当前所在的位置开始,而是始终从git flow feature start branch2开始。这就是git-flow的全部想法。

现在不用担心develop,除非您想做您的问题未明确表达的事情。

合并.git/config的PR,然后为branch1创建PR,一切正常。

相关问题