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

时间:2018-01-24 13:58:33

标签: git visual-studio-code vscode-settings git-shell

自上次VSCode版本以来,有一个弹出窗口询问我是否要允许Git打开。好吧,我允许这个,现在每当我尝试打开集成终端时,Git Shell会在外部打开并关闭集成终端。

我的用户配置:

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

但它没有用,因为git已经在运行。

我想打开PowerShell,并在VSCode中使用git shell,就像之前一样。我怎样才能做到这一点?

UPDATE:

我按照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

我的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",

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,

3 个答案:

答案 0 :(得分:3)

  

我认为这更像是一个git的东西

如果您使用了设置,请卸载Git for Windows 为此,首先,检查(并移动/删除)列出的各种Git配置文件:

git config -l --show-origin

如果这是来自Git设置,你可以在那里看到它。

答案 1 :(得分:3)

我弄清楚造成这个问题的原因或至少是其中的一部分。在另一个项目中,我可以完美地打开终端,所以我比较了这两个项目,发现有问题的项目里面有一个.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"
}

这显然是由VSCode本身创建的,与使用GUI显示的用户配置文件无关。然后我只是注释掉git-bash行并启动了VSCode。从那时起,我摆脱了终端中的git auto启动。现在令人讨厌的是每次加载项目时我都必须登录Github。取消注释该行并未改变该行为。

如果有人能更好地解释那里发生了什么,以及如何恢复github自动登录(不占用我的终端),我会接受一个好的答案。

答案 2 :(得分:0)

https://git-scm.com/download/win

下载并安装git

git的默认路径应为C:\\Program Files\\Git\\bin\\bash.exe

然后转到文件> 偏好设置> 设置,并在您的其他设置下添加此代码:

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

希望这有帮助!