Back

Explore Courses Blog Tutorials Interview Questions
+2 votes
2 views
in DevOps and Agile by (29.3k 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 (50.2k 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.

These git commands will help you while working with Git.

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

Browse Categories

...