2

I merge a remote branch into a local one. After merging I get "deleted by them" files. It means that in remote branch these files are removed, but they have changes in a local branch, that will be lost, if I simply remove files from local branch too.

How to get those changes in a diff form per file? Just to know - what I am losing.

abyss.7
  • 13,882
  • 11
  • 56
  • 100
  • Why not simply checkout the local branch with changes as a new branch? That way, you can switch back (remembering to commit the changes to the newly created branch first) to your other branch to do the remote merge and then execute `git diff merged_branch_name local_changes_branch_name`. – miqh Oct 22 '13 at 06:52
  • 1
    I don't get your point. I definitely want to do merge, and I'm not going to save all changes in deleted files. I want to know - before actual merge-commit - what changes will be lost: then, I may ignore them, or may reimplement them in a new place, or whatever. – abyss.7 Oct 22 '13 at 07:00
  • My suggestion is simply one way of achieving the diff you want. Alternatively, if you insist on not doing any sort of merge before a diff, you could try: `git fetch` (gets remote branch but does _not_ merge it yet) then `git diff` using the name of the remote (i.e. _remotes/origin/master_, not simply something like _master_) as parameters. Once satisfied, you can then execute `git merge`. Does that help? – miqh Oct 22 '13 at 07:28
  • It doesn't help, since `git diff` gives difference between whole file (local) and nothing (remote). – abyss.7 Oct 22 '13 at 07:38
  • To be honest, I am still hazy on understanding _which_ commits you actually want to diff. But if my previous tips do not produce the diff you want, you probably want to look for the common ancestor commit where changes in the local branch diverged from what is in the remote. You should then diff against the local branch HEAD and this ancestor commit to get these so-called changes you want. See this **[link](http://stackoverflow.com/questions/4944376/how-to-check-real-git-diff-before-merging-from-remote-branch)** too, it may clarify better than I have. – miqh Oct 23 '13 at 01:08

1 Answers1

-1

You can use Meldmerge to compare your changes with the incoming ones from the repo. Create a copy of your project folder(Say folder1) and take a fresh pull in that.

Now folder1 is updated with the latest code as on remote repo. Now compare your project folder with folder1 using meld. You can clearly locate the differences per file at the same place and include those in the project folder if required by just a click.

Bijendra
  • 9,467
  • 8
  • 39
  • 66
  • Mmm, and what about CLI? Also, creating copy each time is a little bit expensive - my repo weights ~3Gb. – abyss.7 Oct 22 '13 at 07:04
  • not each time..create the copy once and keep it there..but surely 3Gb is a concern. have a look http://meldmerge.org/help/command-line.html .Though i have not tried this – Bijendra Oct 22 '13 at 07:23
  • found something..hope it helps http://stackoverflow.com/questions/1331385/how-can-i-see-incoming-commits-in-git/1331459#1331459 – Bijendra Oct 22 '13 at 07:25