Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compare foo.bar from two different branches in MAGIT [duplicate]

Tags:

git

emacs

magit

This answer shows how to see the differences between a specific file foo.bar in two different branches in git. My question is how to do this within magit?

like image 995
Dror Avatar asked May 03 '13 12:05

Dror


People also ask

How do I compare two branches in stash?

Currently, the only way to compare branches in Atlassian Stash is to create a pull request first. Otherwise, you can use local git commands to compare arbitrary commits or branches.

How do I compare branches in github?

On the Github, go to the Source view of your project. You will see a link named 'Branch List'. Once the page opens you can see a list of all the remote branches. Hit on the Compare button in front of any of the available branches to see the difference between two branches.

How do you tell the difference in files in git?

You can run the git diff HEAD command to compare the both staged and unstaged changes with your last commit. You can also run the git diff <branch_name1> <branch_name2> command to compare the changes from the first branch with changes from the second branch.


2 Answers

I use magit to complement vc. vc already has this functionality C-u C-x v =

like image 93
event_jr Avatar answered Oct 21 '22 07:10

event_jr


Just wanted to note that this is now directly possible with magit.

In the Magit status buffer, type d to open up the diff popup.

Then limit the diff to your file of interest with =f and the file name.

Finally, do a diff range r and type in the branch that you want to compare to (one can also type in a specific commit on the same branch, see a similar question).

like image 22
Dominik Schrempf Avatar answered Oct 21 '22 06:10

Dominik Schrempf