git安装错误缺少安装候选

Niy*_*n C 10 git ubuntu

我尝试git使用命令在 Ubuntu 12.10 上安装sudo apt-get install git。但我收到这样的错误消息:

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
Run Code Online (Sandbox Code Playgroud)

我该怎么做?

and*_*sky 13

尝试运行以下命令。

sudo rm -vf /var/lib/apt/lists/*
sudo apt-get update
Run Code Online (Sandbox Code Playgroud)


小智 11

首先运行此命令进行更新

sudo apt update 
Run Code Online (Sandbox Code Playgroud)

然后运行这个

sudo apt-get install git
Run Code Online (Sandbox Code Playgroud)


Mic*_*dam 5

git 包应该是可安装的。原则上,如果发生这种情况,您应该验证以下内容。

  • 确保/etc/apt/sources.list文件的内容是正常的。它应该包含如下内容:

    deb http://archive.ubuntu.com/ubuntu precise main restricted universe multiverse
    deb http://archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse
    deb http://security.ubuntu.com/ubuntu precise-security main restricted universe multiverse
    
    Run Code Online (Sandbox Code Playgroud)
  • apt-get update在尝试安装 git 之前,请确保您已运行。

请注意,上面的 sources.list 是为了精确 (12.04)。12.10 被称为量子。但请注意,不再支持12.10 (EOL 是 2014 年 5 月 - 请参阅此处)。因此,您的问题的解决方案可能是服务器上不再存在 12.10 的包源,因此该消息实际上是正确的:在服务器上根本就没有候选人了...

解决方案是至少升级到下一个 LTS 版本 (14.04)。


小智 0

我在这里找到了关于 ubuntu 12 上的 git 的很好的教程。

主要提到了安装前的依赖:

sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev build-essential
Run Code Online (Sandbox Code Playgroud)

并将其用于 git 安装: sudo apt-get install git-core sudo apt-get update

更进一步,它说:一旦安装,您可以从谷歌代码页下载最新版本的 Git。

wget https://git-core.googlecode.com/files/git-1.8.1.2.tar.gz
Run Code Online (Sandbox Code Playgroud)

下载后,解压文件并切换到该目录:

tar -zxf git-1.8.1.2.tar.gz
Run Code Online (Sandbox Code Playgroud)

cd git-1.8.1.2

如果您想进行全局安装,请以您自己的身份安装一次,并以 root 身份安装一次,使用 sudo 前缀:

make prefix=/usr/local all
sudo make prefix=/usr/local install
Run Code Online (Sandbox Code Playgroud)

如果以后需要更新Git,可以使用Git本身来完成。

git clone git://git.kernel.org/pub/scm/git/git.git
Run Code Online (Sandbox Code Playgroud)

去查看教程并给她留言;-)