You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GitHub中分支的分支能否合并/变基?协作场景实操问询

Great questions—let’s walk through each one based on your GitFlow setup and permissions:

1. Can the other developer create a PR for feature/23456 → develop?

Yes, absolutely. Here’s why:

  • Your teammate has permission to push their own feature branches to the repository (they already pushed feature/12345, so this is confirmed).
  • Creating a pull request only requires that the contributor has a branch in the repository to target against develop. Their "read-only" permission on develop only prevents them from directly pushing to or merging into develop—not from opening a PR.
  • That said, they won’t be able to merge the PR themselves; only you (with write access to develop) can approve and complete the merge.

2. Will this "branch of a branch" scenario cause issues on GitHub?

Nope, GitHub fully supports nested feature branches like this. The only thing to watch out for is merge conflicts once you’ve merged feature/12345 into develop—since feature/23456 is based on an older version of feature/12345, it won’t automatically have the updates from develop.

Once your teammate pulls the latest develop into feature/23456 (either via rebase or merge), GitHub will correctly show the PR diff as only the changes unique to feature/23456 (not the already-merged feature/12345 code). No weird GitHub-specific bugs or limitations here—this is a common workflow for parallel development.

3. Should you merge directly, or use rebase? What commands are needed?

This depends on your team’s preference for commit history, but rebase is usually cleaner for feature branches in GitFlow (since it keeps the develop branch history linear). Here’s the step-by-step for your teammate to handle this:

  1. First, have your teammate fetch the latest develop (with your merged feature/12345 changes):
    git checkout develop
    git pull origin develop
    
  2. Switch back to their feature branch and rebase it onto the latest develop:
    git checkout feature/23456
    git rebase develop
    
  3. If conflicts arise during rebase (which is likely), they’ll need to:
    • Open the conflicted files, resolve the differences
    • Stage the fixed files: git add <resolved-file>
    • Continue the rebase: git rebase --continue
    • (If they need to abort the rebase entirely: git rebase --abort)
  4. Since rebasing rewrites the branch’s commit history, they’ll need to force-push the updated branch to GitHub—use --force-with-lease instead of plain --force to avoid accidentally overwriting any unexpected changes:
    git push origin feature/23456 --force-with-lease
    
  5. Once the PR is updated with the rebased branch, you can merge it into develop (this will be a fast-forward merge if no new changes were added to develop in the meantime).

If you prefer to merge instead (for preserving branch history):

If your team wants to keep explicit merge commits showing the parallel development, your teammate can merge develop into their feature branch instead:

  1. Fetch latest develop:
    git checkout develop
    git pull origin develop
    
  2. Merge develop into feature/23456:
    git checkout feature/23456
    git merge develop
    
  3. Resolve any conflicts, stage the files, and commit the merge:
    git add <resolved-file>
    git commit  # Git will auto-generate a merge commit message
    
  4. Push the updated branch normally (no force push needed):
    git push origin feature/23456
    
  5. You can then merge the PR into develop—this will add another merge commit to the history.

Either approach works; rebase just leads to a cleaner, more linear commit history on develop.

内容的提问来源于stack exchange,提问作者smeeb

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:59:05