在git config中从cmd中转义双引号 [英] escape double quotes in git config from cmd

查看:327
本文介绍了在git config中从cmd中转义双引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建一个批处理文件来初始化我的 .gitconfig 文件中的所有键/值。



我有麻烦尝试设置以下部分从cmd:

  [mergetoolp4merge] 
cmd = p4merge $ BASE$ LOCAL$ REMOTE$ MERGED

p>

  git config --global mergetool.p4merge.cmdp4merge \$ BASE\\$ LOCAL \ \$ REMOTE \\$ MERGED\

但结果是:

  [mergetoolp4merge] 
cmd = p4merge \$ BASE\\$ LOCAL \\$ REMOTE\\$ MERGED\

应该从cmd中转义双引号。

解决方案

Windows上的Git:如何设置mergetool?建议:



  • 从git bash会话:




  git config --global mergetool.p4merge.cmd'p4merge.exe \$ BASE\\$ LOCAL \\$ REMOTE\\$ MERGED\'





  • $ c> cmd.exe shell:




 code> git config --global mergetool.p4merge.cmdp4merge.exe \$ BASE\\$ LOCAL \\$ REMOTE \\$ MERGED \ 

这取决于您是否启动 git-bash.bat git-cmd.bat p>

I want to create a batch file that initializes all the key/values in my .gitconfig file.

I have troubles trying to set the following section from cmd:

[mergetool "p4merge"]
    cmd = p4merge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"

I tried:

git config --global mergetool.p4merge.cmd "p4merge \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\""

But the result is:

[mergetool "p4merge"]
    cmd = p4merge \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"

How should I escape that double quotes from cmd?

解决方案

The answer to "Git on Windows: How do you set up a mergetool?" proposes:

  • From a git bash session:

git config --global mergetool.p4merge.cmd 'p4merge.exe \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"'

  • or, from a windows cmd.exe shell:

git config --global mergetool.p4merge.cmd "p4merge.exe \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\""

So it depends if you launched git-bash.bat or git-cmd.bat

这篇关于在git config中从cmd中转义双引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆