简体   繁体   English

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

[英]Start a feature branch in another feature branch

I created ( git flow feature start branch1 ) and published ( git flow feature publish branch1 ) a git flow feature branch based on develop .我创建了( git flow feature start branch1 )并发布了( git flow feature publish branch1 )一个基于develop的 git flow 功能分支。 After them, I have this marked as a Pull Request , that another developer look at the changes in this branch.在他们之后,我将其标记为Pull Request ,让另一位开发人员查看此分支中的更改。 But now I want to work further, so I create a new feature branch ( git flow feature start branch2 ) based on branch1 where is waiting for Pull Request .但是现在我想进一步工作,所以我基于正在等待Pull Request branch1创建了一个新的功能分支( git flow feature start branch2 )。 But after creating branch2 , there are only the files, where in branch1 are ignored (all files, where matched with the condition in .gitignore ).但是在创建branch2 ,只有在branch1中的文件被忽略(所有文件,其中与.gitignore的条件匹配)。

When I checked out branch1 , I see the whole dictionary with all files, but why are in the new created feature branch ( branch2 ) not all files?当我签出branch1 ,我看到了包含所有文件的整个字典,但为什么在新创建的功能分支( branch2 )中不是所有文件? So I can't work further.所以我不能再工作了。

I found the problem, but not the solution:我找到了问题,但没有找到解决方案:

In .git/config file, there is written, that the base from my branch2 the develop branch is, and not branch1 :.git/config文件中,有写,我的branch2基础develop分支,而不是branch1

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

With following command I can move all files from branch1 in branch2 , but the base in the .git/config -file changed not to branch1 ...:使用以下命令,我可以将所有文件从branch1移动到branch2 ,但.git/config -file 中的基数未更改为branch1 ...:

git rebase --onto feature/branch1 develop feature/branch2

Building with this template: git rebase --onto newBase oldBase feature/branch使用此模板构建: git rebase --onto newBase oldBase feature/branch

How can I change the base-branch from my branch2 ?如何从我的branch2更改基本分支 Simply by changing base-branch from branch2 to branch1 in .git/config ?只需将.git/config base-branchbranch2更改为branch1

You could change the base in your .git/config but you should not.您可以更改.git/configbase ,但您不应该这样做。

The base for branch2 is also develop since this is the branch you want to merge to later (after branch1 is already merged). branch2base也是develop因为这是您以后要合并到的分支(在branch1已经合并之后)。

This is also reflected in git flow feature start branch2 , which does not start where you currently are but always from develop .这也反映在git flow feature start branch2 ,它不会从您当前所在的位置开始,而是始终从develop That's the whole idea of git-flow .这就是git-flow的全部想法。

Don't worry about the .git/config now unless you want to do something that your question doesn't specifically express.现在不要担心.git/config除非你想做一些你的问题没有明确表达的事情。

Merge the PR for branch1 and then create the PR for branch2 and everything will work normally.合并branch1的 PR,然后为branch2创建 PR,一切都会正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM