Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git - Changes made in meld (as the difftool) not saved

Tags:

git

git-diff

meld

I followed Jörg W Mittag's answer in this post and have configured meld as the difftool in my git. Now I can view and compare differences of a file in different branches perfectly with this command:

git checkout branch1
git difftool branch1:file.f90 branch2:file.f90

I executed the above command, made and saved changes in meld. However, when I check the file using:

emacs file.f90

The changes I made earlier in meld are not saved at all. I don't understand why this is so; I must have not entirely correctly configured meld as the diff tool. Could any one help me with this problem? Thanks!!

like image 279
user3238512 Avatar asked Jan 26 '14 21:01

user3238512


2 Answers

Because you have explicitly given the branches of both files to be diff'ed, meld is working on temporary copies of both files. Try just giving the name of the non-checked out branch:file; this should cause meld to compare a temporary copy of the given branch:file with the checked out file of the same name.

like image 102
Dipstick Avatar answered Oct 26 '22 17:10

Dipstick


To avoid the need to specify the filename twice, use the following:

git difftool branch -- file

This will compare branch:file with file in the working tree.

Furthermore, to diff the entire working tree with branch, use:

git difftool --dir-diff branch

As mentioned in other answers, if you need to diff branch with other_branch (some branch different from what is currently checked out), you must first check out other_branch before using the above commands.

like image 41
Mark Avatar answered Oct 26 '22 19:10

Mark