How to compare two commits while ignoring merge requests? #45166
Replies: 3 comments 9 replies
-
To get the same diff that you would see in the GitHub UI when using the API, you can use the diff-tree command and pass the SHA of the feature branch and the base branch (in your case, master) as arguments. This will give you a diff that only includes the changes made in the feature branch and not the changes from any merge commits. |
Beta Was this translation helpful? Give feedback.
-
Looking at the network inspector when using github.com, I see this internal API:
So what I am looking for is the public version of that! |
Beta Was this translation helpful? Give feedback.
-
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
-
Select Topic Area
Question
Body
My team follows a common workflow:
feature-x
off ofmaster
feature-x
, adding commitsbase=master
andhead=feature-x
master
is updated by someone else, dogit merge master
intofeature-x
and keep workingOn the GitHub website the diff shown seems to "ignore" the changes from the merge commit. However this is not the same for the API: https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#compare-two-commits
When I compare two commits using the API (in the diff format) and there is a merge commit in between the two, I get a really large diff with all of the merged-in changes as well.
How can I use the API to get the exact same diff I'd see in GitHub's UI?
Beta Was this translation helpful? Give feedback.
All reactions