Is there a way to test if two diffs or patches are equivalent?
Let's say you have the following git commit history, where features F and G are cleanly rebaseable to E:
G / A--B--C--D--E \ F
Due to limitations in our current deployment process, we have the following, somewhat related graph (it's not version controlled)
G' / ------------E' \ F'
F' and G' will ultimately be applied to the head E', in some to be determined order, so it would end up like
------------E'--G'--F'
Is there a way to test that the diff from E' to G' is the same as the patch produced by the git commit of G from B?
I fully realize that in an ideal world, revision control would solve this, and we're getting there, but that's not where we are currently.
You could essentially play both patches on separate checkouts and compare the outputs, but that seems kind of clunky. And comparing the diffs themselves, I'm assuming, wouldn't work because line numbers could change. Even if G' and F' were rebased to E', the patch for F' would ultimately be applied to G', making the diff context of the patch different.
diff contains only the file changes, while the . patch is a serialization of all commits in that PR, with the commit message and file content diff in each.
Compare specific file between two branches In some cases, you may want to see all changes done to a specific file on the current branch you are working on. In order to see the differences done to a file between two branches, use the “git diff” command, specify the two branches and the filename.
You can always perform branch comparisons from Git if you are comfortable interacting directly with the command line tools it offers. Using Git directly gives you access to a couple of distinct commands that make it easy to compare specific parts of your project. Different arguments of git command.
OK, there are a couple of ways to show all files in a particular commit... To reduce the information and show only names of the files which committed, you simply can add --name-only or --name-status flag... These flags just show you the file names which are different from previous commits as you want...
diff <(git show COMMIT1SHA) <(git show COMMIT2SHA)
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