2

If I do git log develop..feature it is going to show me the difference between the develop and feature branches using the hash id.

However, I have rebased one of my branches and the commit hashes are now different even when the commits are the same (because the parent is different).

How can I compare the two branches by commit message?

Note: I am aware that comparing this way is not reliable. It isn't the only diff I will be doing to determine the difference between the branches but it will help me identify any extra commits.

1 Answer 1

1

It depends on what you mean by "compare".

The three-dot notation can tell you all the commits they don't have in common.

git log develop...feature 

If you want to find what commits they have in common by commit message, you could try diffing a sorted list of all the commit title lines.

diff -u <(git log --format='%s' feature..master | sort) <(git log --format='%s' master..feature | sort) 

Or you can rebase them both on top of a common parent where they got the same commits from in the first place. The redundant commits will go away.

Sign up to request clarification or add additional context in comments.

3 Comments

@opticyclic Rather than editing the answer, could you clarify the question? It's not clear to me how you want this compare to happen. Perhaps you could provide a concrete example?
The first line of the question states that using dot notation compare using hash id. The next line explains why I can't use that. The question then asks how to compare by commit message. Your reference to three-dot notation is is not a valid answer because it compares by hash id which I said I can't use. The part about rebasing on a common parent also doesn't answer the question on how to compare by commit message. The middle part is the only relevant part of the answer.
@opticyclic I answered with more than the literal question because this smells like an XY problem; I expect it's easier to let Git fix the branches with rebase than to try and compare and fix them manually. But, again, the situation is not clear to me. Could you please clarify? An example of your branches, how you got them into this situation, and the sort of comparison you'd like to see would help. I realize this was years ago, but it's an interesting problem.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.