Reputation: 3058
We have 2 directories in the project: backend
& frontend
. We're working on same feature branch, let's call it feature-branch
, both FE and BE.
FE is adding changes only to frontend
dir, BE only to backend
dir.
Now I want to merge master
to feature-branch
. However, there are conflicts both in BE & FE. I'm BE engineer, so I don't know how to resolve the FE conflicts. Is there a way to merge only changes from BE dir, push those changes and then ask the FE engineer to merge the FE changes?
p.s. feature-branch
is our main feature branch. We're creating subbranches from that one and direct our PRs towards that feature-branch
. We don't push directly to that branch.
Upvotes: 4
Views: 3144
Reputation: 60547
If you want to do the merge in parts, make the partial merges, then merge those. How you want your history to look afterwards is up to you, the only statement Git cares about for a merge is "this is a correct merge of these ancestors".
The most-excruciatingly-correct way to do it would probably be to do both the partial merges on their own,
One partial merge, not to the feature branch, with just the backend:
git checkout feature^0 # checkout the feature commit bare, this is a wip
git merge --no-commit master # merge master, with manual changes
resolve all the backend conflicts, then
git checkout @ -- frontend # restore untouched frontend directory
git commit -m "backend-only merge of branch 'master'"
git tag WIP/backend-master-merge
Then do it with just the frontend:
git checkout feature^0 # checkout the feature commit bare, this is a wip
git merge --no-commit master # merge master, with manual changes
resolve all the frontend conflicts, then
git checkout @ -- backend # restore untouched backend directory
git commit -m "frontend-only merge of branch 'master'"
git tag WIP/frontend-master-merge
and now merge the results:
git checkout feature
git merge WIP/{frontend,backend}-master-merge
so that nothing shows up on the feature branch that can't pass your integration tests. You could get a simpler command sequence and a simpler-looking history by doing one of the partial merges directly on the feature branch then later merging the other partial result.
Upvotes: 1
Reputation: 5598
Do the merge then checkout the desired directory
git merge --no-commit FE
git checkout HEAD PATH_TO_FRONT_END
git add FILES
git commit -m "Just BE changes!"
Upvotes: 0