如何在Ubuntu 20.04中安装Git



我已经在Virtualbox上安装了Ubuntu 20.04。我试着安装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 update && sudo apt upgrade。如果这不起作用,sudo add-apt-repository ppa:git-core/ppa && sudo apt update

git作为Ubuntu标准软件包的一部分已经有很长的时间了;如果你的实例找不到它,你设法以这样一种方式安装它,即它的在线包存储库对机器不可见,并且你唯一的源将是cd/dvd。。。检查您的/etc/apt/sources.list以查看启用了什么。

您的sources.list设置不正确。复制并通过以下命令到您的终端:

cat <<EOF |sudo tee /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu focal-updates main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb http://archive.canonical.com/ubuntu/ focal partner
EOF
sudo apt update
sudo apt install git

相关内容

  • 没有找到相关文章

最新更新