3

Short of re-installing git or editing the relevant registry key that adds context menus to the shell myself, I was wondering if there was another way to bring back the "Git Bash Here" and "Open command window here" menus?

I am using Windows 7 Home Premium 64-bit.

Water Cooler v2
  • 32,724
  • 54
  • 166
  • 336
  • Possible duplicate of [How to add a "open git-bash here..." context menu to the windows explorer?](http://stackoverflow.com/questions/24386657/how-to-add-a-open-git-bash-here-context-menu-to-the-windows-explorer) – wheeler Mar 30 '17 at 18:41
  • Nothing here explains why git-bash sometimes goes missing from the right click menu. Without knowing why it happens, how can we prevent it happening again? Google took me to another place to search for answers (https://stackoverflow.com/questions/44591955/git-bash-here-is-not-exisiting-in-windows-explorer-right-clickcontext-menu) and that has unfortunately disappeared! – Ivan Jun 26 '18 at 09:22
  • FYI, if you are using Windows 11, there's a post created for that. You can track that availability there: https://stackoverflow.com/questions/70237709/how-to-add-a-git-bash-here-context-menu-option-to-the-windows-explorer-in-wind – David Oganov Apr 13 '22 at 13:18

2 Answers2

7

Checkout this SO question:

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

Update:

So I did a little more research into where the actual git bash and git gui context menu items were stored in the registry. I exported the keys that I had in my registry into a .reg file:

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.\""
Community
  • 1
  • 1
wheeler
  • 2,823
  • 3
  • 27
  • 43
0

In addition to the answer with the theory and the minimal example see the examples for Git (and not only) with user-friendly names, shortcut keys (& in a user-friendly name) and icons in the "win-registry-snippets" repository

Nick Vee
  • 621
  • 2
  • 7
  • 17