How can I use git bash aliases in vscode terminal?

只谈情不闲聊 提交于 2021-01-01 07:02:32

问题


I have several git bash aliases that work fine when I use the git bash terminal, but they dont when I use the vscode integrated terminal? Is there a way to fix this? I do have bash selected in vscode.

After running git config -l --show-origin --show-scope

system  file:C:/Program Files/Git/etc/gitconfig http.sslbackend=openssl
system  file:C:/Program Files/Git/etc/gitconfig http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
system  file:C:/Program Files/Git/etc/gitconfig credential.helper=manager
system  file:C:/Program Files/Git/etc/gitconfig core.editor=nano.exe
system  file:C:/Program Files/Git/etc/gitconfig core.autocrlf=true
system  file:C:/Program Files/Git/etc/gitconfig core.fscache=true
system  file:C:/Program Files/Git/etc/gitconfig core.symlinks=true
system  file:C:/Program Files/Git/etc/gitconfig diff.astextplain.textconv=astextplain
system  file:C:/Program Files/Git/etc/gitconfig filter.lfs.clean=git-lfs clean -- %f
system  file:C:/Program Files/Git/etc/gitconfig filter.lfs.smudge=git-lfs smudge -- %f
system  file:C:/Program Files/Git/etc/gitconfig filter.lfs.process=git-lfs filter-process
system  file:C:/Program Files/Git/etc/gitconfig filter.lfs.required=true
global  file:C:/Users/jgilr/.gitconfig  filter.lfs.smudge=git-lfs smudge -- %f
global  file:C:/Users/jgilr/.gitconfig  filter.lfs.process=git-lfs filter-process

回答1:


Check how VSCode is launched.

Depending on your OS, it could be launched with a different account (or, on Windows, the "System" account), which means it would not benefit from the same "git config --global -l" settings, because its HOME environment variable is different from your bash.

In VSCode integrated terminal, assuming a recent Git, you can launch, to check if you see your aliases:

git config -l --show-origin --show-scope

The solution is:

  • add the aliases in %USERPROFILE%\.gitconfig
  • use the Shell argument -l (--login) for the setting "terminal.integrated.shellArgs.linux", as shown in issue 7263




回答2:


Issue was fixed by adding terminal.integrated.shellArgs.windows": ["--login"] to vscode settings and writing all my aliases to %USERPROFILE%.bash_profile



来源:https://stackoverflow.com/questions/62687445/how-can-i-use-git-bash-aliases-in-vscode-terminal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!