git difftool 问题:未设置 LOCAL、REMOTE 变量
根据文档和此处的各种答案,git difftool 将调用指定的可执行文件(通常是 shell 脚本),并将环境变量 LOCAL 和 REMOTE 设置为文件路径。但当我尝试时,LOCAL 和 REMOTE 未设置。我尝试过以下测试:
git config --global diff.tool mytest
git config --global difftool.mytest.cmd mytest.sh
git config --global difftool.prompt false
with mytest.sh:
#!/bin/sh
echo "LOCAL:$LOCAL REMOTE:$REMOTE"
invoking:
git difftool --tool mytest <commitid> -- <path-to-file>
output:
LOCAL: REMOTE:
有什么建议吗?
According to doc and various answers here git difftool will invoke the specified executable (usually a shell script) with environment variables LOCAL and REMOTE set to the file paths. But when I try, LOCAL and REMOTE are not set. I've tried the following test:
git config --global diff.tool mytest
git config --global difftool.mytest.cmd mytest.sh
git config --global difftool.prompt false
with mytest.sh:
#!/bin/sh
echo "LOCAL:$LOCAL REMOTE:$REMOTE"
invoking:
git difftool --tool mytest <commitid> -- <path-to-file>
output:
LOCAL: REMOTE:
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
手册页的含义是 difftool..cmd 的命令行中可以包含
$LOCAL
和$REMOTE
。这些将被替换为相关的文件路径。这些变量无意导出到您的环境中。为了通过示例进行演示,这里是原始设置的重新设计版本。
What the man page means is that difftool.<tool>.cmd can have
$LOCAL
and$REMOTE
in its command-line. Those will be replaced with the relevant file paths. It isn't intended that those variables are exported into your environment.To demonstrate with an example, here's a re-worked version of your original setup.
这是我一直使用的 diff 包装器(使用 tkdiff):
它使用参数而不是
$LOCAL
和$REMOTE
。This is the diff wrapper I've always used (with tkdiff):
Which uses parameters rather than
$LOCAL
and$REMOTE
.