How to add a "open git-bash here..." context menu to the windows explorer?

GitContextmenuWindows ExplorerWindows Shell-Extension-Menu

Git Problem Overview


How to add a context (aka right click) menu to the windows explorer that, when clicked, opens the git-bash console in the current explorer folder?

Git Solutions


Solution 1 - Git

Step 1. On your desktop right click "New"->"Text Document" with name OpenGitBash.reg

Step 2. Right click the file and choose "Edit"

Step 3. Copy-paste the code below, save and close the file

Step 4. Execute the file by double clicking it

Note: You need administrator permission to write to the registry.

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.\""

And here is your result :

enter image description here

Solution 2 - Git

I had a similar issue and I did this.

Step 1 : Type "regedit" in start menu

Step 2 : Run the registry editor

Step 3 : Navigate to HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\Background\shell. If you don't have the shell key, create one.

Step 4 : Right-click on "shell" and choose New > Key. name the Key "Bash"

Right click on Key. name the Key "Bash"">

Step 5 : Modify the value and set it to "open in Bash" This is the text that appears in the right click.

enter image description here

enter image description here

Step 6 : Create a new key under Bash and name it "command". Set the value of this key to your git-bash.exe path.

enter image description here

enter image description here

enter image description here

Close the registry editor.

You should now be able to see the option in right click menu in explorer

PS Git Bash by default picks up the current directory.

EDIT : If you want a one click approach, check Ozesh's solution below

Solution 3 - Git

The easiest way is to install the latest Git from here. And while installing, make sure you are enabling the option Windows Explorer Integration.

enter image description here

Once you are done, you will get those options in whenever you right click on any folder.

enter image description here

Hope it helps.

Solution 4 - Git

Here are the Registry exports (*.reg files) for Git GUI and Git Bash directly from the Windows installer —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.\""

Git bash:

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.\""

For detail about *.reg files, see “How to add, modify, or delete registry subkeys and values by using a .reg file” from Microsoft.

Solution 5 - Git

You can install git for windows or Github for windows , both give you the choice while installing to add this feature to your windows explorer. You can find it here:

Github for Windows

https://windows.github.com/

Git for Windows

http://git-scm.com/

Solution 6 - Git

What worked for me was almost this, but with the following REGEDIT path:
HKEY_LOCAL_MACHINE/SOFTWARE/Classes/Directory/background/shell and here I created the key Bash, with the value of what I want the display name to be, and then created another key under this named command with the value as the path to git-bash.exe

I'm on Windows 10 and have a fresh git install that didn't add this automatically for some reason (git version 2.12.0 64bit)

Solution 7 - Git

As, @Shaswat Rungta said: "I think the question is more about how to add it after the installation is over."

On my PC(Windows 7) I think that the command "Git Bash here" disappeard after I installed Visual Studio 2017.

I fixt this by downloading and installing Git again.


NOTE: "When installing Git for Windows the context menu options are not 'on' by default. You will have to select them during the install." – @nbushnell (I did this)

Solution 8 - Git

Had a similar issue in adding "Start Command Prompt with Ruby" to context menu as it involves passing parameters along with the patch of cmd. Followed a similar procedure as the solution above

Windows Registry Editor Version 5.00 

[HKEY_CLASSES_ROOT\*\shell\Cmd With Ruby]  
@="Cmd With Ruby"  
"Icon"="C:\\Windows\\System32\\cmd.exe"

[HKEY_CLASSES_ROOT\*\shell\Cmd With Ruby\command]
@="\"C:\\Windows\\System32\\cmd.exe\" \"/E:ON /K
\"C:\\Ruby25-x64\\bin\\setrbvars.cmd\"\" \"--cd=%1\"\""


[HKEY_CLASSES_ROOT\Directory\shell\bash]  
@="Cmd With Ruby"  
"Icon"="C:\\Windows\\System32\\cmd.exe"


[HKEY_CLASSES_ROOT\Directory\shell\bash\command]
@="\"C:\\Windows\\System32\\cmd.exe\" \"/E:ON /K
\"C:\\Ruby25-x64\\bin\\setrbvars.cmd\"\" \"--cd=%1\"\"" 
 
[HKEY_CLASSES_ROOT\Directory\Background\shell\bash]  
@="Cmd With Ruby"  
"Icon"="C:\\Windows\\System32\\cmd.exe"


[HKEY_CLASSES_ROOT\Directory\Background\shell\bash\command]
@="\"C:\\Windows\\System32\\cmd.exe\" \"/E:ON /K
\"C:\\Ruby25-x64\\bin\\setrbvars.cmd\"\" \"--cd=%v.\"\""

Solution 9 - Git

Usually git bash here can be run only on directories so you have to go up a directory and right click on the previous directory then select git bash here (of course on Windows OS).
Note: context menu inside a directory does not have a git bash here option.

Solution 10 - Git

When you install git-scm found in "https://git-scm.com/downloads" uncheck the "Only show new options" located at the very bottom of the installation window

Make sure you check

  • Windows Explorer integration
    • Git Bash Here
    • Git GUI Here

Click Next and you're good to go!

Solution 11 - Git

I updated my git and I marked the option of "Git Bash Here"

Solution 12 - Git

I have already too many programs that want a spot on my PATH list. Rather than pollute my PATH list, I choose instead to add a symbolic link, from an elevated command prompt, like so.

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

While there are exceptions, this works in the majority of cases, including, among others, the 7-zip CLI, selected SysInternals command line tools, the NuGet CLI, and many others.

As a bonus, having the Git Bash command line interface so readily accessible makes activating it from an open command prompt window trivial. With this improvement, I can probably live without yet another item on my context menu for directories.

Solution 13 - Git

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

Solution 14 - Git

You can install TortoiseGit for Windows and include integration in context menu. I consider it the best tool to work with Git on Windows.

Solution 15 - Git

Use Shift + F10 to open the menu of options which appear when right clicked, and then click s to git bash here.

Solution 16 - Git

Add the git path to the Environment-path variable (e.g. C:\Program Files\Git\cmd) by which you can access git from any folder using command line.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionsergejView Question on Stackoverflow
Solution 1 - GitOzeshView Answer on Stackoverflow
Solution 2 - GitShaswat RungtaView Answer on Stackoverflow
Solution 3 - GitSibeesh VenuView Answer on Stackoverflow
Solution 4 - GitrasxView Answer on Stackoverflow
Solution 5 - GitAlexander KludtView Answer on Stackoverflow
Solution 6 - GitE TView Answer on Stackoverflow
Solution 7 - GitMarian07View Answer on Stackoverflow
Solution 8 - GitJeffy JahfarView Answer on Stackoverflow
Solution 9 - Gitqt-xView Answer on Stackoverflow
Solution 10 - GitohmcodesView Answer on Stackoverflow
Solution 11 - Gitthiago rodrigues de santanaView Answer on Stackoverflow
Solution 12 - GitDavid A. GrayView Answer on Stackoverflow
Solution 13 - GitNick VeldView Answer on Stackoverflow
Solution 14 - Gitenrique-carbonellView Answer on Stackoverflow
Solution 15 - GitVijayView Answer on Stackoverflow
Solution 16 - GitRaj AsapuView Answer on Stackoverflow