1、yum卸载
[root@liuqin ~]# yum list installed | grep git
crontabs.noarch 1.11-6.20121102git.el7 @anaconda
git.x86_64 1.8.3.1-20.el7 @updates
libglvnd.x86_64 1:1.0.1-0.8.git5baa1e5.el7 @base
libglvnd-egl.x86_64 1:1.0.1-0.8.git5baa1e5.el7 @base
libglvnd-glx.x86_64 1:1.0.1-0.8.git5baa1e5.el7 @base
linux-firmware.noarch 20170606-56.gitc990aae.el7 @anaconda
lm_sensors-libs.x86_64 3.4.0-4.20160601gitf9185e5.el7 @base
net-tools.x86_64 2.0-0.22.20131004git.el7 @base
xdg-utils.noarch 1.1.0-0.17.20120809git.el7 @base
以上git.x86_64说明已安装
[root@liuqin ~]# yum remove git
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package git.x86_64 0:1.8.3.1-20.el7 will be erased
--> Processing Dependency: git = 1.8.3.1-20.el7 for package: perl-Git-1.8.3.1-20.el7.noarch
--> Processing Dependency: git for package: gettext-devel-0.19.8.1-2.el7.x86_64
--> Running transaction check
---> Package gettext-devel.x86_64 0:0.19.8.1-2.el7 will be erased
---> Package perl-Git.noarch 0:1.8.3.1-20.el7 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================================================================
Removing:
git x86_64 1.8.3.1-20.el7 @updates 22 M
Removing for dependencies:
gettext-devel x86_64 0.19.8.1-2.el7 @base 1.4 M
perl-Git noarch 1.8.3.1-20.el7 @updates 57 k
Transaction Summary
===========================================================================================================================================================================
Remove 1 Package (+2 Dependent packages)
Installed size: 24 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Erasing : gettext-devel-0.19.8.1-2.el7.x86_64 1/3
Erasing : git-1.8.3.1-20.el7.x86_64 2/3
Erasing : perl-Git-1.8.3.1-20.el7.noarch 3/3
Verifying : perl-Git-1.8.3.1-20.el7.noarch 1/3
Verifying : gettext-devel-0.19.8.1-2.el7.x86_64 2/3
Verifying : git-1.8.3.1-20.el7.x86_64 3/3
Removed:
git.x86_64 0:1.8.3.1-20.el7
Dependency Removed:
gettext-devel.x86_64 0:0.19.8.1-2.el7 perl-Git.noarch 0:1.8.3.1-20.el7
Complete!
卸载完毕
2、rpm卸载
[root@liuqin ~]# rpm -qa | grep git
crontabs-1.11-6.20121102git.el7.noarch
libglvnd-egl-1.0.1-0.8.git5baa1e5.el7.x86_64
xdg-utils-1.1.0-0.17.20120809git.el7.noarch
net-tools-2.0-0.22.20131004git.el7.x86_64
libglvnd-1.0.1-0.8.git5baa1e5.el7.x86_64
git-1.8.3.1-20.el7.x86_64
libglvnd-glx-1.0.1-0.8.git5baa1e5.el7.x86_64
lm_sensors-libs-3.4.0-4.20160601gitf9185e5.el7.x86_64
linux-firmware-20170606-56.gitc990aae.el7.noarch
git-1.8.3.1-20.el7.x86_64为已安装版本
[root@liuqin ~]# rpm -e git
error: Failed dependencies:
git = 1.8.3.1-20.el7 is needed by (installed) perl-Git-1.8.3.1-20.el7.noarch
git is needed by (installed) gettext-devel-0.19.8.1-2.el7.x86_64
以上说明有依赖关系,可用--nodeps不查找依赖关系卸载
rpm -e --nodeps git
3、源码安装卸载
如果以上两种方式试过之后,命令行输入git仍然能显示该命令存在,那你可能需要使用这种方式了
[root@liuqin ~]# which -a git
/usr/local/git/bin/git
[root@liuqin ~]# cd /usr/local/git/bin/
[root@liuqin bin]# ls
git git-cvsserver gitk git-receive-pack git-shell git-upload-archive git-upload-pack
[root@liuqin bin]# rm -rf git *
以上用于删除git的可执行文件
[root@liuqin bin]# which -a git
/usr/bin/which: no git in (/usr/local/git/bin:/usr/lib64/qt-3.3/bin:/usr/local/maven/apache-maven-3.5.0/bin::/usr/java/jdk1.8.0_131/bin::/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
[root@liuqin bin]# vim /etc/bashrc
[root@liuqin bin]# source /etc/bashrc
image.png
将/etc/bashrc中git的配置注释掉保存并source生效
[root@liuqin bin]# git
-bash: git: command not found
[root@liuqin bin]# vim /etc/bashrc
[root@liuqin bin]# git --version
-bash: git: command not found
大功告成,以上说明卸载成功!
安装详见老徐的文章http://istester.com/git/118.html
网友评论