E: Package ‘git‘ has no installation candidate

目录

  • 1. 问题
  • 2. 解决方案
  • 3. 参考文献

1. 问题

今天在Linux上安装git如下所示:

apt-get install git -y

结果出现下列错误:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package git is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'git' has no installation candidate

2. 解决方案

针对上面错误,解决方案就是升级我们的:apt-get,使用下面命令

apt-get update

Get:1 file:/var/nvinfer-runtime-trt-repo-5.0.2-ga-cuda10.0  InRelease
Ign:1 file:/var/nvinfer-runtime-trt-repo-5.0.2-ga-cuda10.0  InRelease
Get:2 file:/var/nvinfer-runtime-trt-repo-5.0.2-ga-cuda10.0  Release [574 B]
Get:2 file:/var/nvinfer-runtime-trt-repo-5.0.2-ga-cuda10.0  Release [574 B]
Get:3 file:/var/nvinfer-runtime-trt-repo-5.0.2-ga-cuda10.0  Release.gpg [801 B]
Get:3 file:/var/nvinfer-runtime-trt-repo-5.0.2-ga-cuda10.0  Release.gpg [801 B]
Get:4 file:/var/nvinfer-runtime-trt-repo-5.0.2-ga-cuda10.0  Packages [764 B]
Get:5 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:6 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB]               
Get:7 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [26.7 kB]
Get:8 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [1428 kB]
Get:9 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]      
Get:10 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]   
Get:11 http://archive.ubuntu.com/ubuntu bionic/restricted amd64 Packages [13.5 kB]
Get:12 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages [1344 kB]
Get:13 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [2320 kB]
Get:14 http://security.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [560 kB]
Get:15 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages [186 kB]
Get:16 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [11.3 MB]
Get:17 http://archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [593 kB]
Get:18 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [34.4 kB]
Get:19 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [2202 kB]
Get:20 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [2755 kB]
Get:21 http://archive.ubuntu.com/ubuntu bionic-backports/main amd64 Packages [11.3 kB]
Get:22 http://archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [11.4 kB]
Fetched 23.3 MB in 7s (3502 kB/s)                                              
Reading package lists... Done

然后再次安装就可以了

apt-get install git -y

3. 参考文献

解决: Linux – git: command not found

你可能感兴趣的:(Linux,git,ubuntu,linux)