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


当前回答

步骤1。在桌面上右键单击“新建”->“文本文档”,名称为OpenGitBash.reg

步骤2。右键单击文件,选择“编辑”

步骤3。复制粘贴下面的代码,保存并关闭文件

步骤4。双击该文件执行该文件

注意:您需要管理员权限才能写入注册表。

Windows Registry Editor Version 5.00
; Open files
; Default Git-Bash Location C:\Program Files\Git\git-bash.exe

[HKEY_CLASSES_ROOT\*\shell\Open Git Bash]
@="Open Git Bash"
"Icon"="C:\\Program Files\\Git\\git-bash.exe"

[HKEY_CLASSES_ROOT\*\shell\Open Git Bash\command]
@="\"C:\\Program Files\\Git\\git-bash.exe\" \"--cd=%1\""

; This will make it appear when you right click ON a folder
; The "Icon" line can be removed if you don't want the icon to appear

[HKEY_CLASSES_ROOT\Directory\shell\bash]
@="Open Git Bash"
"Icon"="C:\\Program Files\\Git\\git-bash.exe"


[HKEY_CLASSES_ROOT\Directory\shell\bash\command]
@="\"C:\\Program Files\\Git\\git-bash.exe\" \"--cd=%1\""

; This will make it appear when you right click INSIDE a folder
; The "Icon" line can be removed if you don't want the icon to appear

[HKEY_CLASSES_ROOT\Directory\Background\shell\bash]
@="Open Git Bash"
"Icon"="C:\\Program Files\\Git\\git-bash.exe"

[HKEY_CLASSES_ROOT\Directory\Background\shell\bash\command]
@="\"C:\\Program Files\\Git\\git-bash.exe\" \"--cd=%v.\""

这是你的结果:

其他回答

将gitpath添加到Environment-path变量(例如C:\Program Files\Git\ cmd),通过该变量,您可以使用命令行从任何文件夹访问git。

什么也不做。

只要打开你的git bash终端,输入:

                            git update-git-for-windows

一旦更新完成,这将自动添加“Git Bash here”到您的上下文菜单。

参考这个:https://stackoverflow.com/a/65467670

我已经有太多的程序想要在PATH列表中占有一席之地。为了不污染PATH列表,我选择从升高的命令提示符中添加一个符号链接,如下所示。

mklink C:\bin\git-bash.exe "C:\Program Files\Git\git-bash.exe"

虽然也有例外,但这在大多数情况下都是有效的,其中包括7-zip CLI、选定的SysInternals命令行工具、NuGet CLI和许多其他工具。

另外一个好处是,Git Bash命令行界面易于访问,这使得从打开的命令提示窗口激活它变得很简单。有了这个改进,我可能就可以在目录上下文菜单上不再有另一个项目了。

你可以为windows安装git或为windows安装Github,两者都让你在安装时选择将此功能添加到windows资源管理器中。你可以在这里找到它:

Github for Windows

https://windows.github.com/

Git for Windows

http://git-scm.com/

下面是Registry导出(*。reg文件)Git GUI和Git Bash直接从Windows安装程序-Git GUI:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\git_gui]
@="Git &GUI Here"
"Icon"="C:\\Program Files\\Git\\cmd\\git-gui.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\git_gui\command]
@="\"C:\\Program Files\\Git\\cmd\\git-gui.exe\" \"--working-dir\" \"%v.\""

去抨击:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\git_shell]
@="Git Ba&sh Here"
"Icon"="C:\\Program Files\\Git\\git-bash.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\git_shell\command]
@="\"C:\\Program Files\\Git\\git-bash.exe\" \"--cd=%v.\""

关于*的详细信息。reg文件,请参阅微软的“如何使用.reg文件添加、修改或删除注册表子键和值”。