简体   繁体   English

VSCode自动在终端中打开Git shell - 如何禁用它?

[英]VSCode automatically opens Git shell in terminal - how to disable it?

Since last VSCode version there was a popup asking me if I want to allow Git to open. 从上一个VSCode版本开始,有一个弹出窗口询问我是否要允许Git打开。 Well I allowed this and now every time I try to open the integrated terminal the Git Shell opens externally and closes the integrated terminal. 好吧,我允许这个,现在每当我尝试打开集成终端时,Git Shell会在外部打开并关闭集成终端。

My user config: 我的用户配置:

"terminal.integrated.shell.windows": "C:\\\\WINDOWS\\\\Sysnative\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe"

But it doesn't help because git is already running. 但它没有帮助,因为git已经在运行。

I want to open powershell instead and have git shell inside of VSCode as it was before. 我想打开powershell,并在VSCode中使用git shell,就像之前一样。 How can I achieve this? 我怎样才能做到这一点?

UPDATE: 更新:

I run git config -l --show-origin as VonC suggested: 我按照VonC的建议运行git config -l --show-origin

file:"C:\\ProgramData/Git/config"       core.symlinks=false
file:"C:\\ProgramData/Git/config"       core.autocrlf=true
file:"C:\\ProgramData/Git/config"       core.fscache=true
file:"C:\\ProgramData/Git/config"       color.diff=auto
file:"C:\\ProgramData/Git/config"       color.status=auto
file:"C:\\ProgramData/Git/config"       color.branch=auto
file:"C:\\ProgramData/Git/config"       color.interactive=true
file:"C:\\ProgramData/Git/config"       help.format=html
file:"C:\\ProgramData/Git/config"       http.sslcainfo=D:/TOOLS/Git/mingw64/ssl/certs/ca-bundle.crt
file:"C:\\ProgramData/Git/config"       diff.astextplain.textconv=astextplain
file:"C:\\ProgramData/Git/config"       rebase.autosquash=true
file:"D:\\TOOLS\\Git\\mingw64/etc/gitconfig"    credential.helper=manager
file:C:/Users/myusername/.gitconfig  filter.lfs.clean=git-lfs clean -- %f
file:C:/Users/myusername/.gitconfig  filter.lfs.smudge=git-lfs smudge -- %f
file:C:/Users/myusername/.gitconfig  filter.lfs.process=git-lfs filter-process
file:C:/Users/myusername/.gitconfig  filter.lfs.required=true
file:C:/Users/myusername/.gitconfig  user.name=MYName
file:C:/Users/myusername/.gitconfig  user.email=some@email.com
file:.git/config        core.repositoryformatversion=0
file:.git/config        core.filemode=false
file:.git/config        core.bare=false
file:.git/config        core.logallrefupdates=true
file:.git/config        core.symlinks=false
file:.git/config        core.ignorecase=true
file:.git/config        remote.origin.url=https://github.com/MyProject/my-project.git
file:.git/config        remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
file:.git/config        branch.master.remote=origin
file:.git/config        branch.master.merge=refs/heads/master
file:.git/config        branch.routing.remote=origin
file:.git/config        branch.routing.merge=refs/heads/routing

My VScode user settings: 我的VScode用户设置:

"php.validate.executablePath": "D:/TOOLS/xampp7/php/php.exe",
"php.suggest.basic": false,
"window.zoomLevel": 0,
"workbench.colorTheme": "Monokai",
"workbench.iconTheme": "vs-seti",
"git.path": "D:/TOOLS/Git/cmd/git.exe",
// A glob pattern that defines files and folders to exclude while listing annotations
  "todohighlight.exclude": "{**/node_modules/**,**/bower_components/**,**/bower/**,**/libs/**,**/vendor/**,**/dist/**,**/build/**,**/.vscode/**,**/_output/**,**/*.min.*,**/*.map}",
  "git.autofetch": true,
  "git.confirmSync": false,
  "git.enableSmartCommit": true,
  "explorer.confirmDelete": false,
  "terminal.integrated.shell.windows": "C:\\WINDOWS\\Sysnative\\WindowsPowerShell\\v1.0\\powershell.exe",
  "todo.colors.tag": "#967848",
  "todo.colors.code": "#fbf5cb",

Default settings with the git keyword: 使用git关键字的默认设置:

  "projectManager.git.baseFolders": [],
  "projectManager.git.maxDepthRecursion": 4,
  "git.autofetch": false,
  "git.autorefresh": true,
  "git.checkoutType": "all",
  "git.confirmSync": true,
  "git.countBadge": "all",
  "git.decorations.enabled": true,
  "git.defaultCloneDirectory": null,
  "git.enableCommitSigning": false,
  "git.enabled": true,
  "git.enableSmartCommit": false,
  "git.ignoreLegacyWarning": false,
  "git.ignoreLimitWarning": false,
  "git.ignoreMissingGitWarning": false,
  "git.path": null,

I think that this is more a git thing 我认为这更像是一个混蛋

Then uninstall Git for Windows if you did use the setup. 如果您使用了安装程序,请卸载Git for Windows。
For that, first, check (and move/delete) the various Git config files listed with: 为此,首先,检查(并移动/删除)列出的各种Git配置文件:

git config -l --show-origin

If this is from a Git setting, you could see it there. 如果这是来自Git设置,你可以在那里看到它。

I figured out what's causing this problem or at least a part of it. 我弄清楚是什么导致了这个问题或至少是其中的一部分。 In an another project I could perfectly open the terminal so I compared these two projects and found out that the one with the problem has a .vscode folder with this settings.json inside: 在另一个项目中,我可以完美地打开终端,所以我比较了这两个项目,发现有问题的项目有一个.vscode文件夹,里面有这个settings.json

{
    "terminal.integrated.shell.windows": "D:\\TOOLS\\Git\\git-bash.exe",
    "terminal.integrated.shell.windows": "C:\\WINDOWS\\Sysnative\\WindowsPowerShell\\v1.0\\powershell.exe"
}

Well this has been obviously created by VSCode itself and has nothing to do with the user config file that shows up using the GUI. 这显然是由VSCode本身创建的,与使用GUI显示的用户配置文件无关。 Then I just commented out the git-bash line and started VSCode. 然后我只是注释掉git-bash行并启动了VSCode。 Since then I got rid of git auto starting in the terminal. 从那时起,我摆脱了终端中的git auto启动。 The annoying thing now is that I have to login to Github every time I load the project. 现在令人讨厌的是每次加载项目时我都必须登录Github。 Uncommenting the line didn't change that behavior. 取消注释该行并未改变该行为。

If someone can explain better what's happening there and how to restore the github autologin (without occupying my terminal) I will sill accept a good answer. 如果有人能够更好地解释那里发生了什么以及如何恢复github自动登录(不占用我的终端),我将接受一个好的答案。

Download and install git from https://git-scm.com/download/win https://git-scm.com/download/win下载并安装git

The default path for git should be C:\\\\Program Files\\\\Git\\\\bin\\\\bash.exe git的默认路径应为C:\\\\Program Files\\\\Git\\\\bin\\\\bash.exe

Then go to File > Preferences > Settings and add this code under your other settings: 然后转到文件 > 首选项 > 设置,并在其他设置下添加此代码:

{
[...]
"git.enabled": false,
"git.path": null,
"git.autofetch": false,
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
}

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 git 推入 vscode 终端现在打开浏览器 - git push in vscode terminal now opens a browser 如何在 VSCode 的集成终端中启用 git 自动完成? - How to enable git autocomplete in integrated terminal in VSCode? 如何禁用 VSCode Git Rebase UI - How To Disable VSCode Git Rebase UI 终端中的Git版本与VScode不同 - Git version in terminal not the same as VScode 终端中的 Git 提交打开 VIM,但无法返回终端 - Git commit in terminal opens VIM, but can't get back to terminal 当 VSCode 终端 Git 运行时,VSCode 源代码控制不起作用 - VSCode Source Control is not Working While VSCode Terminal Git Is Vscode 集成终端与 Linux 终端与 git 的工作方式不同 - Vscode integrated terminal working differently than Linux terminal with git 如何在不使用终端的情况下使用 VSCode 对 git 进行变基并使用我们的策略 - How to git rebase and use ours as strategy using VSCode without using the terminal 如何设置vscode在不刷新的情况下自动显示git repo中的修改文件? - How to set vscode to show modified files in git repo automatically without refresh? 我如何在终端中或不在存储库中时使用Shell脚本获取“ git log” - How do I get 'git log' in the terminal or using a shell script when not in a repository
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM