I know that git tracks content and generates a sha based partially on the content. However, the sha is also based upon the parent commit. When I rebase a branch, because my commits now have a different ancestor, all of my commits have different shas.
But what I'm wondering, is there a way to compare two commits (or commit ranges) to see if content-wise, they are the same? This should also be able to tell if a binary change is the same as well.
I'm thinking if there was some way to get the sha for the content without the ancestor information incorporated, that might do it.
Thanks for any and all help,
You can also compare two arbitrary commits in your repository or its forks on GitHub in a two-dot diff comparison. To quickly compare two commits or Git Object IDs (OIDs) directly with each other in a two-dot diff comparison on GitHub, edit the URL of your repository's "Comparing changes" page.
To see the changes between two commits, you can use git diff ID1.. ID2 , where ID1 and ID2 identify the two commits you're interested in, and the connector .. is a pair of dots. For example, git diff abc123.. def456 shows the differences between the commits abc123 and def456 , while git diff HEAD~1..
You can compare files between two Git commits by specifying the name of the ref that refers to the commits you want to compare. A ref may be a commit ID or HEAD, which refers to the current branch. Let's compare two commits in our Git repository. The above command will perform a diff operation across our two commits.
To compare any two commits in your branch, use the Ctrl key to select the two commits that you want to compare. Then right-click one of them and select Compare Commits.
You want the --cherry-mark option to git log which marks commits with an equals sign when their patch content is the same.
git log --decorate --graph --oneline --cherry-mark --boundary A...B
is a great way to compare the rebased branch B with the original branch A. I use this for checking that my commits made using git-tfs are still ok once TFS has been at them.
https://stackoverflow.com/a/23527631/2630028
diff <(git show 123456) <(git show abcdef)
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