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

基于未合并分支开发新功能时的Git分支处理方法

Can I develop feature-b based on feature-a while its merge request is pending?

Absolutely! This is a super common workflow in team development—especially when feature-b depends on code from feature-a—and it works perfectly even while feature-a's merge request (MR) is still in a pending state. Here's a clear, step-by-step guide to pull this off:

  • First, make sure your local feature-a branch is up to date with the remote version (in case you or a teammate pushed changes after your initial MR):
    git checkout feature-a
    git pull origin feature-a
    
  • Create your new feature-b branch directly from the updated feature-a:
    git checkout -b feature-b
    
  • Now you can start developing feature-b just like you would any other branch. Once you're done with changes, stage and commit your work:
    git add .
    git commit -m "Add core functionality for feature-b"
    
  • Push the new feature-b branch to the remote repository:
    git push origin feature-b
    
  • You can even open a merge request for feature-b right away! Just make sure to note in the MR description that it depends on the pending MR for feature-a—this helps your team know the order of operations for merging.

A quick heads-up for later:

If feature-a gets updated (e.g., you make changes based on MR feedback and push them), you'll want to sync those updates to feature-b to avoid conflicts down the line. Here's how:

  1. Switch back to feature-a and pull the latest changes:
    git checkout feature-a
    git pull origin feature-a
    
  2. Switch to feature-b and merge (or rebase) the updated feature-a into it:
    • Merge (keeps a clear merge history):
      git checkout feature-b
      git merge feature-a
      
    • Rebase (rewrites feature-b's commits to sit on top of the latest feature-a, resulting in a cleaner linear history):
      git checkout feature-b
      git rebase feature-a
      
    Just remember—if you've already pushed feature-b to remote, you'll need to force push after rebasing (use git push origin feature-b --force-with-lease to be safe, as it avoids overwriting others' work).

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.27 03:51:51