Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git and DiffTool problems : What do LOCAL and REMOTE point to?

Tags:

git

difftool

Ive been working on getting tortoisemerge working as the difftool option in Git with my .gitconfig file currently showing :

   [diff]         tool = tortoise      [difftool "tortoise"]         cmd = tortoisemerge.exe -mine:$LOCAL -base:$REMOTE      [difftool]         prompt = false 

According to tortoise merge docs the 'mine' command states which file will be shown on the right, in a two way diff.

My question is, what do the LOCAL and REMOTE variables as provided by GIT actually point to? The documentation is a little vague stating that

LOCAL is set to the name of the temporary file containing the contents of the diff pre-image and REMOTE is set to the name of the temporary file containing the contents of the diff post-image.

The problem arises when I modify a file, and then enter 'git difftool' tortoisemerge is started with the working directory file on the LEFT and not the right as I assume. I know I can merely switch the 'mine' and 'local' commands but I was trying to figure out what the local/remote points to and the best way to resolve this issue

like image 845
x1886x Avatar asked Mar 26 '11 05:03

x1886x


People also ask

How does git Difftool work?

git difftool is a Git command that allows you to compare and edit files between revisions using common diff tools. git difftool is a frontend to git diff and accepts the same options and arguments.

How can I tell the difference between local and remote?

You can git branch -a to list all branches (local and remote) and then choose the branch name from the list (just remove remotes/ from the remote branch name. Example: git diff main origin/main (where "main" is the local main branch and "origin/main" is a remote, namely the origin and main branch.)


2 Answers

there are 4 components to this (note that before this step, you would have already done a local-checkin.)

  • The local-checkin that your git tree has: LOCAL
  • The head of the remote repository (that is going to be merged): REMOTE
  • common ancestor to both LOCAL and REMOTE: BASE
  • The file that will be written as a result: MERGED.
like image 127
Sandeep Avatar answered Oct 06 '22 17:10

Sandeep


I think that means that $LOCAL is always the a/whatever in the diff output, while $REMOTE is the b/whatever. In other words, if you do:

 git difftool master experiment -- Makefile 

$LOCAL will be a temporary file showing the the state of Makefile in the master branch, while $REMOTE will be a temporary file showing its state in the experiment branch.

If you just run:

git difftool 

... that shows you the difference between the index and your working tree, so for each file with differences, $LOCAL will be a temporary file that's the same as the version of the file in the index, while the $REMOTE will be the version of the file in your working tree.

like image 26
Mark Longair Avatar answered Oct 06 '22 18:10

Mark Longair