I want to compare "just the file contents" of two branches of a GitHub repository. When I use the default compare view for a pull request for example, it does still show me some diffs, even though the files are identical.
You can reproduce the situation like this:
README.README and push the commit to a new branch duplicate.README of the master branch.README files from both branches now have identical content, yet https://github.com/user/repo/compare/duplicate shows a diff between duplicate and master.I know this diff is being shown because the changes to both files have been introduced by different commits, but sometimes it's more useful to only see the differing file contents, i. e. what would really get changed by merging. In the example above, master wouldn't change at all.
As far as I understand, the git CLI command provides this feature for local folders with its --no-index option. So, I could clone the two branches to my local file system and compare them with git diff --no-index. How can I achieve this without having to clone them first? I want to view the difference online on GitHub.
Update: I don't think the issue has anything to do with the --no-index option. If I download the repository and use git diff locally, I noticed the following: git diff master..duplicate (two dots) won't show a difference and git diff master...duplicate (three dots) will show the same as GitHub's compare online.
Therefore, this question is similar to this one: Github Comparison View for 2 branches is incorrect?
In short: Currently, GitHub's compare view always uses git diff with three dots. More information about the difference between two and three dots also at https://git-scm.com/docs/git-diff
As it's a GitHub repository:
https://github.com/{USER_OR_ORG}/{REPOSITORY}/compare/{BRANCH_1}...{BRANCH_2}.patch
(You can remove the '.patch' to see the difference in GitHub UI)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With