Reputation: 28882
When I merge a branch using the ours strategy, even though the codeline does not change, I end up with a whole lot of new commit messages that I am not interested in (since they have no impact on my codeline.) Is there any way to prevent this?
Upvotes: 0
Views: 43
Reputation: 488183
As ElpieKay noted in a comment, it really is supposed to work this way: git merge -s ours
makes a new merge commit that uses the same snapshot as the current commit. But being a merge commit means that the new commit has two parent commits: the previously-current commit as its first parent, and the other commit—the one you merged—as its second parent:
...--F--G--H--M <-- your-branch (HEAD)
/
...--J--K--L
When you run git log
, git log
's job is to follow all the parents, showing their log messages, unless you tell it not to:
git log --first-parent
This tells Git that at each merge, such as M
, it should follow only the first parent. After showing M
, Git will move back to H
, not to both H
and L
.
Upvotes: 2