I have a few files on one branch (master) and the same files on another branch (develop). I want to output the difference for these files. How do I do that?
Thank you.
I have a few files on one branch (master) and the same files on another branch (develop). I want to output the difference for these files. How do I do that?
Thank you.
To compare two Git branches using the diff command, specify the two branches you want to compare as arguments. You need to use two dots between each branch name. These dots indicate that you want to read the latest commit in each of the branches and compare them:
git diff <branch1>..<branch2>
Suppose we wanted to compare the “master” branch with a branch called “dev-v0.9” in our repository. We could do so using this command:
git diff master dev-v0.9
When this command is executed, a diff will be run between the “master” and “dev-v0.9” branches in our codebase.
Similarly, you can compare specific files across two different branches. To do so, you can use the same syntax as above and additionally specify the file which you want to compare.
Suppose we wanted to compare the file README.md across our “master” and “dev-v0.9” branches. We could do so using this code:
git diff master dev-v0.9 ./README.md
This will compare the file README.md (which is in our current directory, denoted by the “./” syntax) across the “master” and “dev-v0.9” branches.
For reference look at this site: https://careerkarma.com/blog/git-diff/
you can use the git diff command to see the difference.
git diff master..develop