19

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

我的用户配置:

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

但这无济于事,因为 git 已经在运行。

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

更新:

git config -l --show-origin按照 VonC 的建议运行:

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,
4

3 回答 3

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 自动登录(不占用我的终端),我将接受一个好的答案。

于 2018-02-08T20:16:20.577 回答
3

我认为这更像是一个 git 事情

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

git config -l --show-origin

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

于 2018-01-26T17:39:55.387 回答
1

从https://git-scm.com/download/win下载并安装 git

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

然后转到File > Preferences > Settings并在您的其他设置下添加此代码:

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

希望这可以帮助!

于 2018-02-13T13:21:24.210 回答