"Open git bash here" 和 "Open command prompt here" 从 Windows 资源管理器上下文菜单中消失

"Open git bash here" and "Open command prompt here" disappeared from Windows explorer context menu

我自己没有重新安装 git 或编辑相关的注册表项以将上下文菜单添加到 shell,我想知道是否有另一种方法可以恢复 "Git Bash Here" 和 "Open command window here" 菜单?

我正在使用 Windows 7 家庭高级版 64 位。

结帐this 所以问题:

Context menu for right click on folders in left panel of Windows

Explorer or on background of a directory in right panel:

  1. HKEY_CLASSES_ROOT\Directory\Background\shell if you are administrator
  2. HKEY_CURRENT_USER\Software\Classes\directory\Background\shell if you are a normal user

Context menu for right click on folders in right panel of Windows

Explorer:

  1. HKEY_CLASSES_ROOT\Directory\shell if you are administrator
  2. HKEY_CURRENT_USER\Software\Classes\directory\shell if you are a normal user

Context menu for any file:

  1. HKEY_CLASSES_ROOT\*\shell if you are administrator
  2. HKEY_CURRENT_USER\Software\Classes\*\shell if you are a normal user

In all cases:

  1. add a new key under "shell", naming it as you want to name the context menu item
  2. add a new key inside this key, named command (mandatory name)
  3. edit the "default" property in "command" to myprogrampath\path\path\executable.exe %1 to pass the file path and name of the selected file to your custom program

更新:

所以我对实际 git bash 和 git gui 上下文菜单项在注册表中的存储位置做了更多的研究。我将注册表中的密钥导出到 .reg 文件中:

Windows Registry Editor Version 5.00

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

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

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

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

除了理论和最小示例的答案外,请参阅 Git(不仅如此)的示例,其中包含用户友好的名称、快捷键(以及用户友好的名称)和图标在 "win-registry-snippets" repository