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

前端 未结 12 1685
谎友^
谎友^ 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:56

    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

    Step 4 : Right-click on "shell" and choose New > 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.

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

    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

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

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

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

    Hope it helps.

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

    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)

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

    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.

    0 讨论(0)
  • 2020-11-29 17:02

    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/

    0 讨论(0)
  • 2020-11-29 17:12

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

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