【问题标题】:Start a feature branch in another feature branch在另一个功能分支中启动一个功能分支
【发布时间】:2020-12-15 23:24:13
【问题描述】:

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

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

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

.git/config 文件中,我的branch2 develop 分支的base 是,而不是branch1

[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 更改为不为branch1...:

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

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

如何更改我的branch2 中的base-branch?只需将 base-branchbranch2 更改为 branch1 in .git/config?

【问题讨论】:

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


    【解决方案1】:

    您可以更改.git/config 中的base,但不应该这样做。

    branch2base 也是 develop,因为这是您稍后要合并到的分支(在 branch1 已经合并之后)。

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

    现在不用担心.git/config,除非你想做一些你的问题没有明确表达的事情。

    合并branch1的PR,然后创建branch2的PR,一切正常。

    【讨论】:

      猜你喜欢
      • 2017-07-04
      • 2017-07-01
      • 2013-01-31
      • 1970-01-01
      • 2010-12-04
      • 2019-12-17
      • 1970-01-01
      • 2019-02-28
      • 1970-01-01
      相关资源
      最近更新 更多