如何添加一个上下文(又名右键单击)菜单到windows资源管理器,当单击时,在当前资源管理器文件夹中打开git-bash控制台?


当前回答

当你在“https://git-scm.com/downloads”中安装git-scm时,取消位于安装窗口最底部的“只显示新选项”

一定要检查

Windows资源管理器集成 Git Bash在这里 Git GUI在这里

单击Next,您就可以开始了!

其他回答

另一种选择,但使用PowerShell脚本。

这基本上是一个PowerShell脚本,它几乎与这个答案相同(它也添加了图标)。

创建文件(addOpenGitBashHereContextMenu.ps1),粘贴下面的代码,并从PowerShell运行它。

您可能需要更改exePath以指向您的git可执行文件。 也改变contextMenuText如果你想改变上下文菜单中的文本。

$exePath = $env:USERPROFILE + '\scoop\apps\git\current\git-bash.exe'
$contextMenuText = 'Open Git Bash Here'
$regEntryName = 'git_shell'

$regPathShell = 'HKCU:\SOFTWARE\Classes\Directory\Background\shell'
$regPathContextMenu = $regPathShell + '\' + $regEntryName
$regPathCommand = $regPathContextMenu + '\command'
$user = $env:UserName

echo "Setting '$contextMenuText' context menu..."
echo "  User name: '$user'"
echo "  Register path: '$regPathCommand'"
echo "  Executable path: '$exePath'"

# Key: shell
If (-NOT (Test-Path $regPathShell)) {
   New-Item -Path $regPathShell
}

# Key: regEntryName
If (-NOT (Test-Path $regPathContextMenu)) {
   New-Item -Path $regPathContextMenu -Value $contextMenuText

   # Add Icon to context menu
   Set-ItemProperty -Path $regPathContextMenu -Name 'Icon' -Value $exePath
}

# Key: command
If (-NOT (Test-Path $regPathCommand)) {
   New-Item -Path $regPathCommand -Value $exePath
}

我更新了我的git并标记了“git Bash Here”选项

我在一台新的Windows 10 Pro公司笔记本电脑上安装git -2.38.1-64位时遇到了这个问题。

我尝试了几种方法……并考虑了一个regedit脚本(道德上相当于“护士-电锯!”)…但是通过简单地卸载和重新安装Git(作为“Admin”)解决了这个问题。

具体地说:

Control Panel > Programs/Features > Uninstall Git Reboot Windows Reinstall Git-2.38.1-64-bit as "Admin" Carefull check all the options, especially: "Windows Explorer Integration: Git Bash Here, Git GUI Here <= These are checked by default ... and I'm sure they were both "Y" on the initial install I copied my .gitconfig ("C:\Users\USERNAME.gitconfig") from another PC <= I don't believe this was "essential" ...but I thought I'd mention it... Browse to a local Git repo and verify the Git context menus work <= Success after reinstall!

对我有用的几乎是这个,但有以下REGEDIT路径: HKEY_LOCAL_MACHINE/SOFTWARE/Classes/Directory/background/shell,在这里我创建了密钥Bash,值是我想要显示的名称,然后在这个命名命令下创建了另一个密钥,值作为git-bash.exe的路径

我在Windows 10上安装了一个新的git,由于某种原因没有自动添加这个(git版本2.12.0 64bit)

尝试更新git。对于windows用户,您可以通过cmd简单地输入命令“git update-git- For -windows”来更新git。

当完成后,你可以简单地在你想要打开gitbash的目录内右键单击,并检查它是否显示“gitbash here”。如果它没有显示任何东西,试着在那里寻找“显示更多选项”并点击它。现在,你可以看到了。