【发布时间】:2021-04-29 12:10:24
【问题描述】:
我重新发布这个,因为它不是重复的。请查看我的编辑。
有人问过here,但没有为 PowerShell 提供解决方案。给出的解决方案不适用于 PowerShell(特别是 VSCode 中的 PowerShell 5.1)。
我试过了
git config --global mergetool.vscode.cmd '"code --wait $MERGED"'
但我丢失了双引号(即相应的 .gitconfig 文件中没有双引号)。仅供参考,单引号是传递 $MERGED 作为字符串文字所必需的,并且没有 PowerShell 尝试扩展它。
我也试过
echo '"code --wait $MERGED"' | git config --global mergetool.vscode.cmd
git config --global mergetool.vscode.cmd '`"code --wait $MERGED`"'
git config --global mergetool.vscode.cmd @'
code --wait $MERGED
'@
但没有任何效果。有没有办法在 PowerShell 中做到这一点?
另外,我研究了this question,以及解决方法
git config --global mergetool.vscode.cmd '\"code --wait $MERGED\"'
也没有
git config --global mergetool.vscode.cmd "\"code --wait $MERGED\""
也没有
git config --global mergetool.vscode.cmd ('"code --wait $MERGED"' -replace '"', '\"')
也不起作用。 (我不使用 PowerShell Core、v7 或其任何跨平台变体)。
【问题讨论】:
标签: powershell double-quotes git-config