Как удалить git версии 1.6.5.1 из Mac OS X 10.5.8
Как удалить git версии 1.6.5.1 из Mac OS X 10.5.8?
5 ответов
Если which git возвращает /usr / local/git / bin/git, как указал Джимми,
должен делать трюк
недавно мне пришлось обновить с 1.9.3 до 2.2.1 на Mac OSX 10.10.1
Я успешно запустил установщик для 2.2.1, но командная строка «git —version» все еще показывала 1.9.3.
оказывается, 2.2.1 был успешно установлен в /usr/local/git / bin и каталог был добавлен в мой путь. Однако 1.9.3 был установлен в /usr / bin, который появился в моей переменной пути оболочки перед /usr / local/git / bin, и поэтому вызывался до обновления версия.
Это было исправлено путем запуска » sudo rm-rf / usr/bin / git*» и перезапуска командной строки.
FYI: если вы думаете, что у Вас аналогичная проблема, вы можете найти различные версии git на своем пути, запустив «type-a git»
можно сделать which git чтобы получить путь к двоичному файлу git. Должно быть довольно ясно, где установлен материал git из этого. Я считаю, что графический установщик помещает его в /usr/local/git по умолчанию. Просто удалите этот каталог, и если вы хотите, удалите его из своего PATH переменная окружения также.
Я знаю, что этот вопрос конкретно касается git 1.x, но если вы на git 2.x, в вашем каталоге git есть сценарий удаления. В моем случае это было:
How to uninstall Git (Apple Git-75) from Mac?
I am unable to install Git from my Mac. I am running MacOS Sierra. I have tried all solutions available, but can’t seem to figure out how to install Git from my Mac.
Here is the screenshot of the version of Git installed on my Mac.
4 Answers 4
just install the latest git by brew
the new git version will replace apple git as default
There’s nothing for you to do. The git you refer to is a part of the operating system. It’s not user-installable. You do not want to un-install it.
If you want a different version, install it using e.g MacPorts or homebrew and use port select git or brew link , respectively, to choose the preferred version.
I had the exact same problem today. I wanted to use the latest git version as default instead of Apple Git. After a couple of hours, here is what helped me —
- Install latest (or whichever you want) version of git
- Make note of the location where new git binary got downloaded. In my case, it got downloaded at /usr/local/git/bin/git
Backup Apple Git binary to some location (just in case)
$ sudo cp /Applications/Xcode.app/Contents/Developer/usr/bin/git /tmp/git-apple
Overwrite system’s git with above downloaded git binary
brandonsimpson / reinstall_git_brew.md
Re-installing Git on Mac OSX with Brew
This is helpful if you’ve previously installed git from source on OSX, and other compilers can’t find the correct path. You need to remove the current version of git, then re-install with brew.
Uninstall git if installed manually
Check which git you’re running:
output should be similar to this: /usr/bin/git
Remove that git install
Re-install git with brew
Check which git you’re now running:
Should now say: /usr/local/bin/git
This comment has been minimized.
Copy link Quote reply
yilliot commented Mar 31, 2018
sudo rm -rf /usr/bin/git wont work for El Capitan due to SIP restriction
simple solution is create alias
This comment has been minimized.
Copy link Quote reply
kungfumike commented Jun 1, 2018
This comment has been minimized.
Copy link Quote reply
novonimo commented Dec 29, 2018 •
consider that for change in bin folder (which is read-only) you must disable SIP System Intergradation Protection in your mac:
1- reboot your mac
2- press and hold ⌘ R until seeing the apple’s logo
3- from recovery menu utils>Terminal
csrutil disable
reboot
now you can remove bin’s stuff
note that: after this change re-enables it using this command:
csrutil enable
This comment has been minimized.
Copy link Quote reply
sidonaldson commented Mar 14, 2019
sudo rm -rf /usr/bin/git wont work for El Capitan due to SIP restriction
simple solution is create alias
brew does this anyways 🙂
This comment has been minimized.
Copy link Quote reply
rezaabdolmaleki commented Jul 3, 2019
that’s great. working for me. thanks 😉
This comment has been minimized.
Copy link Quote reply
titoniubo commented Jul 25, 2019
I follow the instructions and then I am being requested to enter a password.
I do enter the password, but I get an error message:
Thanks for your help.
This comment has been minimized.
Copy link Quote reply
peterHernandez8451 commented Sep 9, 2019
I have gone through the steps you listed in this instruction set, however once I run the «sudo rm -rf /usr/bin/git/» I get the error
rm: /usr/bin/git: Operation not permitted
I am currently running MacOS Mojave v.10.14.6.
and I have Xcode installed (if that means anything).
Please advise.
-Pete8451
This comment has been minimized.
Copy link Quote reply
HadiYaac commented Mar 21, 2020
I have gone through the steps you listed in this instruction set, however once I run the «sudo rm -rf /usr/bin/git/» I get the error
rm: /usr/bin/git: Operation not permitted
I am currently running MacOS Mojave v.10.14.6.
and I have Xcode installed (if that means anything).
Did you found out a solution for your problem?? I got the same error «Operation not permitted» and I’ve been struggling for days with this problem
This comment has been minimized.
Copy link Quote reply
aonrobot commented Jul 31, 2020
I have gone through the steps you listed in this instruction set, however once I run the «sudo rm -rf /usr/bin/git/» I get the error
rm: /usr/bin/git: Operation not permitted
I am currently running MacOS Mojave v.10.14.6.
and I have Xcode installed (if that means anything).
Please advise.
-Pete8451
Did you found out a solution for your problem?? I got the same error «Operation not permitted» and I’ve been struggling for days with this problem
This comment has been minimized.
Copy link Quote reply
peterHernandez8451 commented Aug 26, 2020
Hey people! I was able to get this issue resolved. However i had to install manually (not using brew initially).
I followed the steps from the Git website to reinstall Git.
https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
It automatically updated the git version i had on my Mac. Having XCode on my device did not effect the install. I know this may seem broad, but it worked for me!! hope this helps!
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
naomik / uninstall-GHfM.sh
#! /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 » $ |
remove_dir » $ |
echo » *** Removing preferences… « |
if [ -e » $ |
then |
cp -f » $ |
fi |
defaults delete com.github.GitHub |
defaults delete com.github.GitHub.LSSharedFileList |
echo » *** Removing caches… « |
rm -rf » $ |
echo » *** Stopping and removing Conduit… « |
launchctl remove com.github.GitHub.Conduit |
rm -rf » $ |
echo » *** Removing SSH key… « |
find $ |
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 <> \; |
This comment has been minimized.
Copy link Quote reply
ghost commented Jul 29, 2014
This comment has been minimized.
Copy link Quote reply
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
This comment has been minimized.
Copy link Quote reply
webngt commented Oct 7, 2014
How to safely and cleanly delete command line tools that were installed with github for Mac?
This comment has been minimized.
Copy link Quote reply
ProteusCortex commented Oct 8, 2014
Line 52 through line 60:
This comment has been minimized.
Copy link Quote reply
ghost commented Nov 25, 2014
Thanks guys! That’s a useful resource!
This comment has been minimized.
Copy link Quote reply
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
This comment has been minimized.
Copy link Quote reply
johnnyji commented Jan 8, 2015
I second, that. these instructions are really vague and don’t help us beginners at all.
This comment has been minimized.
Copy link Quote reply
billycc commented Jan 10, 2015
- Click the ‘Raw’ link at the top of the page.
- File > Save-as
- Put it into your Downloads folder, keep the original name (uninstall-GHfM.sh)
- Open Terminal (from Applications folder / Utilities folder)
- Put the following into Terminal:
sudo bash
/Downloads/uninstall-GHfM.sh
This comment has been minimized.
Copy link Quote reply
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:
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!
This comment has been minimized.
Copy link Quote reply
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.
This comment has been minimized.
Copy link Quote reply
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.
This comment has been minimized.
Copy link Quote reply
the-real-tokai commented Jul 14, 2015
There’s something more which this script doesn’t catch, it seems:
(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.
This comment has been minimized.
Copy link Quote reply
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
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).
This comment has been minimized.
Copy link Quote reply
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.
This comment has been minimized.
Copy link Quote reply
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.
This comment has been minimized.
Copy link Quote reply
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)
This comment has been minimized.
Copy link Quote reply
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 ; )
This comment has been minimized.
Copy link Quote reply
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.
This comment has been minimized.
Copy link Quote reply
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.
This comment has been minimized.
Copy link Quote reply
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:
What else can be done to remove a GIT from my mac. ? Thank you.