Search code examples
gitdiffgit-branchgit-diffworking-directory

How do I call git diff on the same file between 2 different local branches?


Is there a way to check the difference between the working directory in my current branch against the working directory of another branch in a specific file? For example, if I'm working in branch A on file 1, I want to compare the difference with file 1 on branch B.


Solution

  • Use the git diff branch branch filename syntax:

    git diff branchA branchB -- file.cs
    

    put the two names of your branches and optionally use the -- filename option to specify one file! Good luck, let me know if you have issues.