Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.5k views
in Technique[技术] by (71.8m points)

git - (gitflow) My feature branch contains previous commit not yet merged on other branches

I'm working in a master develop fb branch way on git.

I create a fb feature branch from develop

Once my work is done, I push fb to origin/fb and do a pull request (with azuredevops) on fb to develop then fb to master

In the pull request to master I can see previous commits before the branch creation which are other merges on develop

Develop
---P0---P1---P2-------------------
             |               FB
             ----M1----M2--------

Master
---P0-----------------------------

I don't want P1 and P2 to be merged on master because other developers are waiting for tests before merging onmaster

What are my options?

  • Create a branch from P0 (and cherry-pick my fbcommits to fix my case), only P1 and P2 want to be merged too, but in the future if there are other previous non commited commits?
  • I saw a previous thread where you create a branch from master, cherry-pick fb's commits into it and merge this branch to master... Seems complex.
  • Is there a way to merge only fb's commits or is it anti-pattern?

What is the correct gitflow for this? In general when do we create a feature branch?

Thank you in advance!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

As a workaround, we could create branch fb from P0 and create branch fa from P2, then work on the branch fb.

Once my work is done, we push fb to origin/fb and do a pull request (with azuredevops) on fb to develop then fb to master, it will not merge P1 and P2 to the branch master.

And if we need the commit P1 and P2, we could push the branch fa to origin/fa and do a pull request to merge the commit P1 and P2


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...