We have a challenge with how things have been merged into two different branches in our (public) Git repository.
We have two branches:
master (commits: a, b, c, d, e) maintenance-8.x.x (commits: a, x, y, z) Different feature branches have been merged into each of these branches (via GitHub PRs)
Goal: Create version-8.1 containing:
- All commits from maintenance-8.x.x (x, y, z)
- Only some commits from master (c, e) — excluding b, d
Later merge maintenance-8.x.x changes back into master.
My first thought was to branch version-8.1 from maintenance-8.x.x, then cherry-pick or rebase all of the many commits from master that we want in 8.1. However, I've run into two problems, and I need help figuring out how to avoid these two problems or deal with them.
First, if the commits are rebased or cherry-picked, we end up with the same changes being applied with different commit IDs. That causes the issues discussed here: Git commits are duplicated in the same branch after doing a rebase
I already got a few such duplicate commits in master before I stopped to ask for help.
The other problem is I found myself having to resolve the same conflicts over and over as described here by @Whymarrh: Git workflow and rebase vs merge questions
How can we achieve this selective merge without:
- Creating duplicate commits that mess up future merges?
- Resolving the same conflicts repeatedly?
The actual repo involved is https://github.com/iNavFlight/inav/