Git 终端中的版本与 Visual Studio 代码中的不同

Git version in the terminal is not the same as in Visual Studio Code

我尝试使用 Homebrew (brew) 在 Mac 终端上更新 Git,除了终端中的目录不同外,一切看起来都很好。命令“which git”给我 /opt/homebrew/bin/git,版本是 2.34.

但在 Visual Studio 代码中显示 /usr/bin/git。这里的版本是2.30.

我该如何解决这个问题?

检查设置“Git Path”是否直接设置为/usr/bin/git

如果是这样,您可以删除该设置:VSCode 将从 $PATH 中选取 git

只要whichgit在/usr/bin/git之前显示/opt/homebrew/bin/git就OK了

OP MadCodex adds in :

I just deleted the brew git and everything come to normal again

我不推荐那个“解决方案”,因为 brew git is the one which is supposed to be here

the discussion 开始,在 ~/.zshr 中添加 export PATH="/opt/homebrew/bin:$PATH" 并重新启动 VSCode 就足够了。