git installation error missing installation candidate

这一生的挚爱 提交于 2020-11-29 06:55:18

问题


I tried installing git on Ubuntu 12.10 using the command sudo apt-get install git. But I am getting error message like this:

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

What am I supposed to do further?


回答1:


Try running below commands.

sudo rm -vf /var/lib/apt/lists/*
sudo apt-get update



回答2:


The git package should be installable. In principle if something like this occurs, you should verify the following.

  • Make sure that the contents of your /etc/apt/sources.list file is sane. It should contain something like this:

    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
    
  • Make sure you have run apt-get update before trying to install git.

Note that the above sources.list is for precise (12.04). 12.10 is called quantal. But note that 12.10 is not supported any more (EOL was May 2014 - see here). So the solution to your problem might be that the package sources for 12.10 don't exist any more on the server, so the message is in fact correct: on the server there simply is no candidate any more...

The solution would then be to upgrade to at least the next LTS version (14.04).




回答3:


I found a nice tutorial about git on ubuntu 12 here.

It mainly mentioned the dependencies prior to install:

sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev build-essential

and to use this for the git installation: sudo apt-get install git-core sudo apt-get update

and further more it says: Once they are installed, you can download the latest version of Git from the google code page.

wget https://git-core.googlecode.com/files/git-1.8.1.2.tar.gz

After it downloads, untar the file and switch into that directory:

tar -zxf git-1.8.1.2.tar.gz

cd git-1.8.1.2

If you want to do a global install, install it once as yourself and once as root, using the sudo prefix:

make prefix=/usr/local all
sudo make prefix=/usr/local install

If you need to update Git in the future, you can use Git itself to do it.

git clone git://git.kernel.org/pub/scm/git/git.git

Go and check the tutorial and leave her a comment ;-)




回答4:


First run this command to update

sudo apt update 

Then run this

sudo apt-get install git


来源:https://stackoverflow.com/questions/30932121/git-installation-error-missing-installation-candidate

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!