Reputation: 20287
In the following git scenario:
A -- B1 -- B2 -- B3
\- C1 -- C2 -- C3
I would like to merge C into B, producing another revision D, such that there are NO changes between B3 and D. In other words, the result is:
A -- B1 -- B2 -- B3 -- D
\- C1 -- C2 -- C3 -/
and D is identical to B3.
Using git merge --strategy-option ours
doesn't quite do the right thing: it resolves conflicts in favor of B, but still merges non-conflicting changes.
Upvotes: 1
Views: 134
Reputation: 45173
I would use
git commit-tree B^{tree} -p B -p C -m "Merge from C but accept no changes"
This prints a commit, which you can fast-forward merge.
The commit-tree
says "create a commit whose tree is identical to what is currently in B. Its parents are the current values of B and C." You can then fast- forward this commit into either B or C.
Upvotes: 2
Reputation: 1796
Jefromi's answer here should help. Basically, assuming the master
branch points to C
and better_branch
points to B
, this should work:
git checkout better_branch
git merge --strategy=ours master # keep the content of this branch, but record a merge
git checkout master
git merge better_branch # fast-forward master up to the merge
Upvotes: 2