How to add a “open git-bash here…” context menu to the windows explorer?

前端 未结 12 1684
谎友^
谎友^ 2020-11-29 16:15

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?

相关标签:
12条回答
  • 2020-11-29 16:47

    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 :

    0 讨论(0)
  • 2020-11-29 16:48

    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)

    0 讨论(0)
  • 2020-11-29 16:49

    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.\"\""
    
    0 讨论(0)
  • 2020-11-29 16:49

    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.

    0 讨论(0)
  • 2020-11-29 16:49

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

    0 讨论(0)
  • 2020-11-29 16:54

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

    0 讨论(0)
提交回复
热议问题