Johann
Johann

Reputation: 29867

Find all changes between two branches in git

I would like to compare two branches and see all the differences between the two. In Android Studio, you can select a branch and select Compare. But this brings up a dialog that shows a list of all the commits done on the current branch. You then select what commit you want to compare to the other branch. But this is not what I want. I don't want to have to go through each commit and compare differences. This is even problematic because older commits will have code that is no longer valid.

If I only select the last commit from my current branch, I only see changes between that commit and the branch being compared to. But my real goal is to see all changes between the current commit and the branch being compared to. How can I do that?

Basically, when I work on a task, I create a branch from some other branch (such as develop) to do my task on. After I have completed my task, I want to compare all the changes to the original task in order to prepare it for code reviewing.

Upvotes: 5

Views: 2300

Answers (3)

Moraigna
Moraigna

Reputation: 73

From the Git toolbar, right-click on the branch you want to compare to and select "Show Diff with working Tree" as seen here:Diff with working Tree

You will get this view:

Double-click on a file to get the Diff view:

One caveat is that you can't use this option with master for some reason. You can use it from master, but that won't let you make changes on your branch as you go. To get around this, I just create a local branch from master and compare with that one.

I really like this method because it will work with submodules!

Upvotes: 4

Mitch Thornton
Mitch Thornton

Reputation: 1001

I compare by right clicking my 'app' directory --> git --> compare with branch

Comparing

Upvotes: 1

EncryptedWatermelon
EncryptedWatermelon

Reputation: 5598

From the console you can do git diff master..develop

If you want a better view use gitk
gitk master..develop
Select the tip of master and then right-click on the tip of develop and select "Diff selected -> this". That will show you the changes to all files in one set.

Upvotes: 0

Related Questions