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
678 views
in Technique[技术] by (71.8m points)

github - Merge non-merged feature branch into another feature branch with Git

My company has a Git workflow that looks something like this:

  • Create feature branch from pristine branch (we use a base branch called "develop", but you can think of this as "master")
  • Do the work you need to do in this feature branch, and commit your changes
  • Occasionally, rebase your feature branch with the develop branch
  • When the work in your feature branch is complete, commit and push to the remote feature branch on GitHub
  • Create a pull request to merge your feature branch into the develop branch, which gets code reviewed by another developer
  • Once the code review is completed, the feature branch is merged into the develop branch, and the feature branch is deleted

This works when you're dealing with a serial workflow, but when you've pushed your changes from your feature branch and are waiting on the other developer to review and merge your changes, you probably want to take on another piece of work, which means repeating the above process.

In our case, we're currently creating our feature branches from the develop branch, so the work I just completed isn't yet available (it's still in limbo, waiting to be merged into the develop branch by another developer). The question I have is, what if the work I'm doing in my new feature branch depends on the work I just completed in my previous feature branch? Should I be initially branching my new feature branch from my as-of-yet unmerged feature branch instead of the develop branch? If I've already created my new feature branch from the develop branch, is getting the changes I'm missing from the unmerged branch as simple as doing a git merge [unmerged-branch] within my new branch?

Hopefully this explanation -- as well as the workflow itself! -- makes sense. I've gotten myself into some weird situations where I'm unclear the state of my code, so I'm trying to figure out a workflow that gives me the flexibility to merge in changes from other feature branches while still getting upstream changes at any time.

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

The question I have is, what if the work I'm doing in my new feature branch depends on the work I just completed in my previous feature branch? Should I be initially branching my new feature branch from my as-of-yet unmerged feature branch instead of the develop branch?

The way you're describing it, yes, you would. However, I'd be concerned about potentially going down the path of working off of "unapproved / unreviewed" work, as if your code review results in significant changes, you may find yourself redoing a lot of work.

If I've already created my new feature branch from the develop branch, is getting the changes I'm missing from the unmerged branch as simple as doing a git merge [unmerged-branch] within my new branch?

Yep. Should be. :)


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

...