46

I have a little question: How can I remove the "git bash here" and "git gui here" from my menu context in my Documents directory?

I have tried:

  1. Reinstalling the Git-2.15.0-64-bit with unchecked options.
  2. Removing the keys from:
[-HKEY_CLASSES_ROOT\Directory\background\shell\git_gui]
[-HKEY_CLASSES_ROOT\Directory\background\shell\git_shell]
[-HKEY_CLASSES_ROOT\Directory\Shell\git_gui]
[-HKEY_CLASSES_ROOT\Directory\Shell\git_shell]

I didn't have the git_gui and git_shell in HKEY_LOCAL_MACHINE.

Removing the keys gave me a good result -> Git isn't appearing in most of my directories but it still appears in my Documents (the place where I have all my projects from NetBeans to Android Studio).

Does anyone have a similar problem? Could someone help?

Yun
  • 3,056
  • 6
  • 9
  • 28
  • 1
    Is this helpful? (Obviously would need to go in reverse) https://stackoverflow.com/questions/24386657/how-to-add-a-open-git-bash-here-context-menu-to-the-windows-explorer – JDB Nov 02 '17 at 21:47
  • 1
    This isn't a programming question. Try superuser.com – MrJLP Nov 03 '17 at 00:04
  • this answer worked (for many): https://stackoverflow.com/a/35530299/1486850 – JinSnow Oct 31 '18 at 10:24

8 Answers8

58

I Think I've found other reference about it. I've delete mine on

HKEY_CLASSES_ROOT\LibraryFolder\background\shell

Based on https://stackoverflow.com/a/32490883/4906348, Quite simple, I never think about it. You should see like this.

The Git Bash here on Library Background

From This Before Registry delete

To This. It works. After Registry Delete

Note
For Windows 10, there may be also keys in HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell and/or HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\git_shell which you may have to delete as well.

Morse
  • 8,258
  • 7
  • 39
  • 64
Benyamin Limanto
  • 775
  • 10
  • 24
  • 6
    Thanks. Regarding the current version (2.16.2.windows.1 on Win10 x64), there are also keys (Bash and possibly GUI) within HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell that would need removed, as well. – clicheName Mar 17 '18 at 06:13
  • Yep that's true, I think that search function in regedit isn't working properly until it miss thing like this man! – Benyamin Limanto Mar 17 '18 at 10:37
  • And this is the answer I was looking for! Thanks! – Dawid Dave Kosiński May 13 '18 at 14:17
  • 1
    I found `git_shell` and `git_gui` here too: `Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\git_shell` – Anthony Mar 13 '19 at 02:21
49

You need to delete these keys:

HKEY_CLASSES_ROOT\Directory\shell\git_gui

HKEY_CLASSES_ROOT\Directory\shell\git_shell

HKEY_CLASSES_ROOT\LibraryFolder\background\shell\git_gui

HKEY_CLASSES_ROOT\LibraryFolder\background\shell\git_shell

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\git_gui

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\git_shell

This works with Windows 10.1803 and Git 2.25.0 (YMMV with other Windows/Git versions).

Virendra
  • 665
  • 5
  • 6
20

You can run this using PowerShell to simplify things and automate. Since you must remove keys from HKLM, it must run with elevated privileges. Use "#Requires -RunAsAdministrator" if you want to save it in a PS1 script.

#Requires -RunAsAdministrator
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT -ErrorAction SilentlyContinue

$path = "HKLM:\SOFTWARE\Classes\Directory\background\shell\git*
HKLM:\SOFTWARE\Classes\Directory\shell\git*
HKLM:\SOFTWARE\Classes\LibraryFolder\background\shell\git*
HKCR:\Directory\Background\shell\git*
HKCR:\Directory\shell\git*
HKCR:\LibraryFolder\background\shell\git*" -split '\n'

Remove-Item -Confirm:$false -Recurse -Path $path
PollusB
  • 1,726
  • 2
  • 22
  • 31
  • This worked like a charm, just what I needed. I use 'choco install git.install' for windows 'auto-install' script. This can cleanup the unwanted stuff after install. – arberg May 22 '20 at 15:10
  • 8
    TRY CHOCO install git.install --params "/NoShellIntegration" It will install it the way you want. – PollusB May 25 '20 at 03:48
  • 1
    OH, I didn't know choco could have custom package arguments. Thank you, it worked beautifully: `choco install git.install --params /NoShellIntegration` – arberg May 26 '20 at 07:19
  • Unfortunately the powershell script didn't do anything for me :-/ but thanks for the tipp @PollusB, this worked perfectly! – skjerns Sep 16 '20 at 07:59
  • @skjerns. Did you ran the script with elevated console (Runas Admin) ? – PollusB Oct 29 '20 at 19:11
  • 1
    @arberg The only problem with CHOCO is: It doesn't remember the arguments when you upgrade GIT. Even when you enable [x] useRememberedArgumentsForUpgrades. So my script still make sense after an upgrade. – PollusB Oct 29 '20 at 19:12
2

I personally prefer a non-destructive approach to solving issue, as that makes it a lot easier to reverse. Here’s one such approach:

  • Open regedit.exe
  • Find the key
    HKEY_CLASSES_ROOT\Directory\shell\git_shell
    
  • Add a new DWORD (32-bit Value) named HideBasedOnVelocityId
  • Assign it a value of 006698a6 (hex)

Should look something like this

Repeat the process for:

  • HKEY_CLASSES_ROOT\Directory\shell\git_gui
    
  • HKEY_CLASSES_ROOT\LibraryFolder\background\shell\git_shell
    
  • HKEY_CLASSES_ROOT\LibraryFolder\background\shell\git_gui
    
  • HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\git_shell
    
  • HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\git_gui
    

And it should be gone from the context menu everywhere.

BromTeque
  • 21
  • 5
  • Hmm. What does `HideBasedOnVelocityId` do? What does this value provide? Do you have a source for where you discovered this? Why would this be preferred over the accepted answer, which has been validated by the community? – Jeremy Caney Nov 18 '21 at 00:21
  • 1
    @JeremyCaney I'm currently investigating what exactly `HideBasedOnVelocityId` does myself. I've noticed it works across multiple context menu additions. E.g. I also removed VSC from the context menu with it. As to why it's preferred. I personally prefer a non-destructive way to solve issues. Makes a lot easier to reverse. I have however noticed a flaw with it. It doesn't hide the option from the context menu if you right click *a* folder, but it works if you right-click inside a folder. Currently looking into why and how to fix it. – BromTeque Nov 19 '21 at 01:25
  • @JeremyCaney I can't track down any documentation for `HideBasedOnVelocityId`, so I'm giving up for now, as I lack keyword/where-to-look knowledge. My point still stands, I prefer a non-destructive, easily reversible solution above deleting registry entries. I figured out how to remove git from the context menu when right-clicking a folder, not inside a folder, and has updated my solution so. My solution is also more applicable to Windows 10. While the original solution, again, suggests deleting the associated registry entries. – BromTeque Nov 19 '21 at 17:55
  • That’s unfortunate about the documentation! Though, I suppose, a lot of registry keys remain poorly documented. How did you discover this? I’ve elevated the relevant parts of your comment to your answer. Since it sounds like your edit addresses the flaw you were referring to above, I didn’t include that. Thanks for following up on this, and putting such care into your answer. – Jeremy Caney Nov 19 '21 at 18:04
  • 1
    @JeremyCaney I found the solution while looking for a way to remove VSC from the context menu. [link](https://superuser.com/a/1178368) I tried applying it to Git as all the solutions I found just parroted "delete this, delete that", and it worked. – BromTeque Nov 20 '21 at 12:35
  • I've made a script that does the process automatically. I'm unsure about the rules and stackoverlfow etiquette of posting self-made scripts so I'm posting it here instead of editing my answer. [Script can be found here](https://github.com/BromTeque/Remove-Git-From-Context-Menu/blob/master/RemoveGitFromContextMenu.reg) To save the file right click "Raw", then "Save link as...", then save it as ".reg" file. RUN AT YOUR OWN RISK! I AM NOT RESPINSIBLE FOR YOUR ACTIONS AND WHAT YOU DO WITH, OR HOW YOU USE THIS SCRIPT! – BromTeque Mar 11 '22 at 00:39
1

It's been a bit late, however someone might find it useful. I didn't have to mess around with the Registry editor or something. What worked for me is just:

  1. Uninstall git normally (from the Settings>Apps or Control Panel).
  2. Restart PC and install git again.
  3. During installation, uncheck "Windows explorer integrations".

I'm using git version 2.38.1 on windows 10.

Ananta Raha
  • 1,011
  • 5
  • 14
0

First, you need to cleanup the unwanted context menu entries in the registry, as described in "How to Clean Up Your Messy Windows Context Menu".
Typically in:

HKEY_CLASSES_ROOT\Directory\shell
HKEY_CLASSES_ROOT\Directory\shellex\ContextMenuHandlers

Then you need to make sure you install Git for Windows with the Portable self-extracting archive: PortableGit-2.15.0-64-bit.7z.exe.
Once extracted in any folder you want, you can add said folder to your %PATH%, and you will be able to use Git without any extra contextual menu entry anywhere.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks for your answer, but I want to remove git from my computer, the context menu is cleared only in some cases, in the Documents folder it still exists. Did you have a problem like this? – Dawid Dave Kosiński Nov 06 '17 at 12:40
  • @DawidDaveKosiński No and the link I provide should get rid of the entry in Document as well. Plus I only uncompress the Portable version, so I never get to see any contextual menu. – VonC Nov 06 '17 at 12:42
  • i'ill try the link later because at the moment I'm not on my computer. – Dawid Dave Kosiński Nov 06 '17 at 13:23
0

Depending on Windows version you have those folders in your registry:

HKEY_CLASSES_ROOT\Directory\shell\git_gui
HKEY_CLASSES_ROOT\Directory\shell\git_shell
HKEY_CLASSES_ROOT\LibraryFolder\background\shell\git_gui
HKEY_CLASSES_ROOT\LibraryFolder\background\shell\git_shell
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\git_gui
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\git_shell

Go to each folder and create new String Value with name LegacyDisable that would resolve an issue immediately. If you want to revert changes, just delete that string.

Here is the picture with the details: LegacyDisable

li key
  • 1
  • 2
0

Top answers are good enough, but I recommend do not edit register manually. It's better to use specific app for enabling/disabling shell menu items - ShellMenuView by Nirsoft: ShellMenuView with selected Git &GUI Here and Git Bash Here

cijic
  • 1