如何在 ubuntu 中安装 git

如何在 ubuntu 中安装 git

我想在我的 ubuntu 上安装 git 我在终端中使用这个命令

sudo apt-get install git

但它会出现错误:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 git : Depends: liberror-perl but it is not installable
E: Unable to correct problems, you have held broken packages.

答案1

 sudo apt-get autoremove <package name>
 sudo apt-get autoclean

如果不起作用:

删除 sources.list 文件并创建新的 sources.list...

sudo rm /etc/apt/sources.list 

然后输入

sudo software-properties-gtk 

在此处输入图片描述 这将打开 software-properties-gtk 并自动创建一个 newsources.list。

然后将服务器更改为美国或您选择的任何其他服务器。您必须从新对话框中启用存储库才能创建新的 sources.list。

勾选所有框然后单击“恢复”,再单击“关闭”。

需要恢复默认存储库

 sudo apt-get update && sudo apt-get dist-upgrade -y

(最好在安装之前备份此文件,以便在发生此类情况时进行恢复)

现在安装 GIT:

 sudo apt-get install git

相关内容