Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带有Git的可移植VSCode-相对Git路径_Git_Visual Studio Code_Vscode Settings - Fatal编程技术网

带有Git的可移植VSCode-相对Git路径

带有Git的可移植VSCode-相对Git路径,git,visual-studio-code,vscode-settings,Git,Visual Studio Code,Vscode Settings,我正在尝试使用Git设置VSCode的可移植版本。我将portable git放在VSCode可执行文件文件夹中的。\tools\git下 我使用以下内容编辑了设置文件: { "git.path": "C:\\my-folder\\tools\\Git\\bin\\git.exe" } 这样做效果很好 但如果我改为以下内容,git将不再工作: { "git.path": ".\\tools\\Git\\bin

我正在尝试使用Git设置VSCode的可移植版本。我将portable git放在VSCode可执行文件文件夹中的。\tools\git下

我使用以下内容编辑了设置文件:

{
    "git.path": "C:\\my-folder\\tools\\Git\\bin\\git.exe"
}
这样做效果很好

但如果我改为以下内容,git将不再工作:

{
    "git.path": ".\\tools\\Git\\bin\\git.exe"
}
根据我的研究,VSCode似乎不支持设置文件中的相对路径


有人知道这方面的解决方法吗?

我使用的解决方法是:

  • 不在VSCode设置中设置路径
  • 通过脚本启动VSCode,该脚本将首先设置VSCode工作所需的文件夹,包括
    C:\my folder\tools\Git\bin
该脚本(可以在
C:\my folder\tools
中)可以:

  • 找到它自己的路径(它当前所在的位置)
  • 使用该路径作为相对于自身的其他路径的基础
它可以从以下内容开始:

@echo off
setlocal enabledelayedexpansion

for %%i in ("%~dp0.") do SET "script_dir=%%~fi"
cd /d "%script_dir%" || echo "unable to cd to '%script_dir%'"&& exit /b 1

set PATH=%PATH%;%script_dir%\Git\bin
%script_dir%\VSCode\bin\code.cmd