Git 和 DiffTool 问题:LOCAL 和 REMOTE 指向什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5440610/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git and DiffTool problems : What do LOCAL and REMOTE point to?
提问by x1886x
Ive been working on getting tortoisemerge working as the difftool option in Git with my .gitconfig file currently showing :
我一直致力于让 Tortoisemerge 作为 Git 中的 difftool 选项工作,我的 .gitconfig 文件当前显示:
[diff]
tool = tortoise
[difftool "tortoise"]
cmd = tortoisemerge.exe -mine:$LOCAL -base:$REMOTE
[difftool]
prompt = false
According to tortoise merge docsthe 'mine' command states which file will be shown on the right, in a two way diff.
根据tortoise 合并文档,“mine”命令以两种方式差异显示哪个文件将显示在右侧。
My question is, what do the LOCAL and REMOTE variables as provided by GIT actually point to? The documentationis a little vague stating that
我的问题是,GIT 提供的 LOCAL 和 REMOTE 变量实际上指向什么?该文件是一个有点含糊指出,
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.
LOCAL 设置为包含 diff 前映像内容的临时文件的名称,REMOTE 设置为包含 diff 后映像内容的临时文件的名称。
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
当我修改一个文件,然后输入 'git difftool' tortoisemerge 是用左边的工作目录文件启动的,而不是我假设的右边时,就会出现问题。我知道我只能切换“我的”和“本地”命令,但我试图找出本地/远程指向的内容以及解决此问题的最佳方法
采纳答案by Mark Longair
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:
我认为,这意味着,$LOCAL
总是a/whatever
在差异中输出,而$REMOTE
为b/whatever
。换句话说,如果你这样做:
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.
$LOCAL
将示出的状态的临时文件Makefile
中的master
分支,而$REMOTE
将表示其状态的临时文件experiment
分支。
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.
...这向您展示了索引和您的工作树之间的差异,因此对于每个有差异的文件,$LOCAL
将是一个与索引中文件版本相同的临时文件,而$REMOTE
将是文件的版本在您的工作树中。
回答by Sandeep
there are 4 componentsto this (note that before this step, you would have already done a local-checkin.)
这有4 个组件(请注意,在此步骤之前,您已经完成了本地签入。)
- 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.
- 您的 git 树具有的本地签入:LOCAL
- 远程仓库的负责人(即将合并):REMOTE
- LOCAL 和 REMOTE 的共同祖先:BASE
- 结果将写入的文件:MERGED。
回答by Anup
I am using TortoiseSvn for merge and diff and is working as expected. While in diff, it shows my working copy on the right. My .gitconfig with TortoiseSvn is as follows
我正在使用 TortoiseSvn 进行合并和差异,并且按预期工作。在 diff 中,它在右侧显示我的工作副本。我与 TortoiseSvn 的 .gitconfig 如下
[diff]
tool = tortoise
[merge]
tool = tortoise
[mergetool "tortoise"]
cmd = TortoiseMerge.exe -base:\"$BASE\" -mine:\"$LOCAL\" -theirs:\"$REMOTE\" -merged:\"$MERGED\"
[difftool "tortoise"]
cmd = tortoisemerge.exe -mine:\"$REMOTE\" -base:\"$LOCAL\"