Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Completely uninstall GitHub for Mac
#!/bin/bash
function remove_dir () {
rm -rf "$1_"
if [ -d "$1" ]
then
mv "$1" "$1_"
fi
}
echo "*** Removing saved user, repositories, and orgs…"
remove_dir "${HOME}/Library/Application Support/GitHub for Mac"
remove_dir "${HOME}/Library/Application Support/com.github.GitHub"
echo "*** Removing preferences…"
if [ -e "${HOME}/Library/Preferences/com.github.GitHub.plist" ]
then
cp -f "${HOME}/Library/Preferences/com.github.GitHub.plist" "${HOME}/Library/Preferences/com.github.GitHub.plist_"
fi
defaults delete com.github.GitHub
defaults delete com.github.GitHub.LSSharedFileList
echo "*** Removing caches…"
rm -rf "${HOME}/Library/Caches/GitHub for Mac" "${HOME}/Library/Caches/com.github.Github"
echo "*** Stopping and removing Conduit…"
launchctl remove com.github.GitHub.Conduit
rm -rf "${HOME}/Library/Containers/com.github.GitHub.Conduit"
echo "*** Removing SSH key…"
find ${HOME}/.ssh -name "*github*_rsa" | while read KEY
do
ssh-add -dK "$KEY.pub"
mv -f "$KEY" "$KEY.bak"
mv -f "$KEY.pub" "$KEY.pub.bak"
done
echo "*** Removing keychain items…"
security -q delete-internet-password -s github.com/mac
security -q delete-generic-password -l 'GitHub for Mac — github.com'
security -q delete-generic-password -l 'GitHub for Mac SSH key passphrase — github.com'
echo "*** Removing command line utility…"
if [ -e "/usr/local/bin/github" ]
then
sudo rm -f /usr/local/bin/github
fi
if [ -e "/Library/LaunchDaemons/com.github.GitHub.GHInstallCLI.plist" ]
then
sudo rm -f /Library/LaunchDaemons/com.github.GitHub.GHInstallCLI.plist
fi
echo "*** Removing git symlinks…"
find /usr/local -lname '*GitHub.app*' -exec sudo rm -f {} \;
@ghost

This comment has been minimized.

Copy link

ghost commented Jul 29, 2014

how do i run this?

@rfreiberger

This comment has been minimized.

Copy link

rfreiberger commented Aug 24, 2014

7habib, you need to save this file with the .sh extenstion, then run the following from your command prompt. $ sudo bash ./.sh

@webngt

This comment has been minimized.

Copy link

webngt commented Oct 7, 2014

How to safely and cleanly delete command line tools that were installed with github for Mac?

@ProteusCortex

This comment has been minimized.

Copy link

ProteusCortex commented Oct 8, 2014

Line 52 through line 60:

if [ -e "/usr/local/bin/github" ]
then
    sudo rm -f /usr/local/bin/github
fi

if [ -e "/Library/LaunchDaemons/com.github.GitHub.GHInstallCLI.plist" ]
then
    sudo rm -f /Library/LaunchDaemons/com.github.GitHub.GHInstallCLI.plist
fi
@ghost

This comment has been minimized.

Copy link

ghost commented Nov 25, 2014

Thanks guys! That's a useful resource!

@RedBullion

This comment has been minimized.

Copy link

RedBullion commented Dec 16, 2014

hey @rfreiberger
re: 7habib, you need to save this file with the .sh extenstion, then run the following from your command prompt. $ sudo bash ./.sh

where do I save the .sh file? I tried saving it in docs but got: bash: ./.sh: No such file or directory

@johnnyji

This comment has been minimized.

Copy link

johnnyji commented Jan 8, 2015

I second, that... these instructions are really vague and don't help us beginners at all...

@billycc

This comment has been minimized.

Copy link

billycc commented Jan 10, 2015

Instructions:

  1. Click the 'Raw' link at the top of the page.
  2. File > Save-as
  3. Put it into your Downloads folder, keep the original name (uninstall-GHfM.sh)
  4. Open Terminal (from Applications folder / Utilities folder)
  5. Put the following into Terminal:
    sudo bash ~/Downloads/uninstall-GHfM.sh
  6. Hit the "return" key
  7. When prompted, enter your admin password (and hit "return" after)
@ariana-paris

This comment has been minimized.

Copy link

ariana-paris commented Feb 21, 2015

It's probably also worth checking whether some GIT environment variables have been added to your ~/.bash_profile, as I found the following when I was cleaning up after the Mac client:

# GIT Details
export GIT_AUTHOR_NAME="my_work_name"
export GIT_AUTHOR_EMAIL=my_work_email_address
export GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"
export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"

These were overriding any user settings in local Git config files which was very irritating. Hope this helps anyone else with this problem who came across this gist as I did!

@ckib16

This comment has been minimized.

Copy link

ckib16 commented Mar 5, 2015

Thanks for this. It worked great.

I will say, it's disappointing that GitHub for Mac requires this level of user involvement for a complete uninstall. It is a free tool, so I can't complain too much. But it was surprising to find that we have to resort to this stuff still in 2015.

@nezhyborets

This comment has been minimized.

Copy link

nezhyborets commented Mar 30, 2015

It's due to Mac system, all the apps you move to trash leave a lot of file being not deleted.

@the-real-tokai

This comment has been minimized.

Copy link

the-real-tokai commented Jul 14, 2015

There's something more which this script doesn't catch, it seems:

$ cat /var/db/com.apple.xpc.launchd/loginitems.501.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.github.GitHub.Conduit</key>
    <string>com.github.GitHub</string>
    <key>version.com.github.GitHub.Conduit</key>
    <string>204</string>
</dict>
</plist>

(the 501 in the filename is the ID of my local user)

Note: Do not just delete the file. There could be GitHub-unrelated things in it.

@tomsmeding

This comment has been minimized.

Copy link

tomsmeding commented Oct 15, 2015

@the-real-tokai Very true; there's also another file there (/var/db/com.apple.xpc.launchd/disabled.501.plist) with some GitHub stuff in it. Don't know what it actually sets, whether it lists disabled things, determines what is disabled, or something else, but there's probably two lines about github there saying

    <key>com.github.GitHub.Conduit</key>
    <false/>

You might want to delete those two lines. Since it's a write-protected file, and cleaning it up doesn't seem so necessary, I wouldn't recommend novice users to try doing anything about it. Otherwise, you might want to try to sudo nano it (or vim or emacs or whatever).

@danielmatei

This comment has been minimized.

Copy link

danielmatei commented Oct 26, 2015

How do I remove GIT from my system? I have Macbook Air (El Capitan), git version 2.4.9 (Apple Git-60).
The command: "which git" outputs: "/usr/bin/git". I can't remove anything from there even with sudo, it says: "Operation not permitted". Please advise, I want to completely remove Git from my system.

@j0rdsta

This comment has been minimized.

Copy link

j0rdsta commented Mar 15, 2016

Sorry for bumping an old gist, but has anyone had any luck in updating this for GitHub Desktop (the newer version of GitHub for Mac)? I haven't tried the code but it looks like it's fairly tied to GitHub for Mac.

@eriktrom

This comment has been minimized.

Copy link

eriktrom commented May 30, 2016

@j0rdsta - i just used it to uninstall the newest version on mac, worked fine (got rid of com.github.github default setting at least, which was my need)

@ljrose

This comment has been minimized.

Copy link

ljrose commented Sep 8, 2016

Thank you you who wrote this handy program. And you who asked questions even beginners like myself can understand (as well as the answer that got posted as a result). Very useful for me - teaching and constantly having to clean up messes made by others ; )

@rayhendricks

This comment has been minimized.

Copy link

rayhendricks commented Sep 7, 2017

Whiip it's 2017 and we still need this script although app cleaner + sudo rm -f /usr/local/bin/github should also do the trick.

@othyn

This comment has been minimized.

Copy link

othyn commented Nov 19, 2017

+1 for AppCleaner + sudo rm -f /usr/local/bin/github, works like a dream!

Had to do a complete clean as the app was mistaking one repo as another, no amount of cloning/cache clear outs/debugging would solve it. Might just go back to CLI only.

@Sgryt87

This comment has been minimized.

Copy link

Sgryt87 commented Jul 25, 2018

I installed GIT from dmg file. I've tried different approaches to remove GIT from my mac and reinstall with brew. Regardless, it is not successefull, after these

sudo rm -rf /usr/bin/git/
sudo rm /etc/paths.d/git
sudo rm /etc/manpaths.d/git
sudo pkgutil --forget --pkgs=GitOSX.Installer.git[A-Za-z0-9].[a-z].pkg
brew uninstall git

I still see a git on my mac ( 'which git' returns : /usr/bin/git).

Also, I tried to run the script from above,having these errors running the .sh file:

/Users/sgryt/Downloads/uninstall-GHfM.sh: line 1: {rtf1ansiansicpg1252cocoartf1561cocoasubrtf200: command not found
/Users/sgryt/Downloads/uninstall-GHfM.sh: line 2: syntax error near unexpected token }' /Users/sgryt/Downloads/uninstall-GHfM.sh: line 2: {\fonttbl\f0\fmodern\fcharset0 Courier;}'

What else can be done to remove a GIT from my mac... ? Thank you.

@alexsandercoelho

This comment has been minimized.

Copy link

alexsandercoelho commented Jul 16, 2020

Tks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.