无法在 Ubuntu 15.10 上安装 git

无法在 Ubuntu 15.10 上安装 git

我尝试通过 安装 git 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

我也尝试过sudo apt-get install git-core并收到此错误

E: Unable to locate package git-core

由于我目前的 Stack Overflow 声誉不允许在此处发布超过 2 个链接。因此,这里是pastebin 链接对于 的输出grep '^[^#]' /etc/apt/sources.list

执行“sudo apt-get update”后出现错误:

获取失败。网络不可访问。

这是完成输出

编辑: 输出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

答案1

首先检查是否可以 ping 网关,无论它是什么,例如

ping 192.168.0.1(你的网关在这里)

如果您修改并回复检查路由是否正确,请暂时禁用网络管理器

sudo service network-manager stop

sudo ifconfig eth0(your adapter) 192.168.0.12/24(your ip) up
sudo route add default gw 192.168.0.1(your gateway)
sudo -i
echo "nameserver 208.67.222.222" > /etc/resolv.conf (opendns dont change these two)
echo "nameserver 208.67.220.220" >> /etc/resolv.conf

检查路线

route

然后做

sudo apt-get update && sudo apt-get install git

如果一切正常,则相应地更改网络管理器中的设置,如果 sudo apt-get update有效,但是

sudo apt-get install git

不起作用,然后手动执行以下步骤

1)安装依赖项

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

继续访问 git 项目的页面,获取所需的 git 版本GitHub

您看到的版本当你到达项目页面时,就是正在积极提交的分支。如果你想要最新的稳定版本,你应该将分支更改为最新的非“rc”标签

2)接下来,在页面右侧,右键单击下载 ZIP 按钮并选择类似于“复制链接地址”的选项

3)

wget https://github.com/git/git/archive/v1.9.2.zip -O git.zip

你的版本会有所不同

4)

unzip git.zip
cd git-*

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

4)现在你已经安装了 git,如果你想升级到更高版本,你可以简单地克隆存储库,然后构建和安装

git clone https://github.com/git/git.git

要查找用于克隆操作的 URL,请导航到项目所需的分支或标签GitHub页面,然后复制右侧的克隆网址

这将在当前目录中创建一个新目录,您可以在其中重建软件包并重新安装新版本,就像上面所做的那样。这将覆盖旧版本

5)

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

相关内容