+2 votes
1 view
in Devops and Agile by (25.5k points)
edited by

I have a script that works fine in one branch and is broken in another. I want to look at the two versions side-by-side and see what's different. Are there any ways to do this?

To be clear I'm not looking for a compare tool (I use Beyond Compare). I'm looking for a git diff command that will allow me to compare the master version to my current branch version to see what has changed. I'm not in the middle of a merge or anything. I just want to say something like

git diff mybranch/myfile.cs master/myfile.cs

1 Answer

+2 votes
by (42.6k points)
edited by

git diff will show you the differences between commits use the below commands

git diff mybranch master -- myfile.cs

Or

git diff mybranch..master -- myfile.cs

In the case of the second command, either side is head it may be omitted.

Master..mybranch will compare master with mybranch

Thus, you can compare the files from two different branches.

For more information please go through the following tutorial to get more info about git:

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...