今天打算在Linux使用git拉取github上的代码,结果出现如下所示的问题:
(pytorch) root@dev-zzx-share:~/wyf/ModelStealing# git clone https://github.com/zlh-thu/StealingVerification.git
bash: git: command not found
于是下面就开始我的解决问题之旅。
上面提示的错误就是我没有在Linux上安装git,所以使用下面命令即可:
apt-get install git -y
安装完成后又出现了下面错误:
(pytorch) root@dev-zzx-share:~/wyf/ModelStealing# apt-get install git -y
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
网上查了些资料说我的apt-get 版本太低,所以需要升级下,输入下面这句命令:
apt-get update
输入下面这句命令:
apt-get install git -y
出现下面这些提示就大功告成了:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
git-man less libcurl3-gnutls liberror-perl
Suggested packages:
git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
git git-man less libcurl3-gnutls liberror-perl
0 upgraded, 5 newly installed, 0 to remove and 235 not upgraded.
Need to get 5079 kB of archives.
After this operation, 34.9 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 less amd64 487-0.1 [112 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libcurl3-gnutls amd64 7.58.0-2ubuntu3.16 [218 kB]
Get:3 http://archive.ubuntu.com/ubuntu bionic/main amd64 liberror-perl all 0.17025-1 [22.8 kB]
Get:4 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 git-man all 1:2.17.1-1ubuntu0.9 [803 kB]
Get:5 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 git amd64 1:2.17.1-1ubuntu0.9 [3923 kB]
Fetched 5079 kB in 4s (1449 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package less.
(Reading database ... 84893 files and directories currently installed.)
Preparing to unpack .../less_487-0.1_amd64.deb ...
Unpacking less (487-0.1) ...
Selecting previously unselected package libcurl3-gnutls:amd64.
Preparing to unpack .../libcurl3-gnutls_7.58.0-2ubuntu3.16_amd64.deb ...
Unpacking libcurl3-gnutls:amd64 (7.58.0-2ubuntu3.16) ...
Selecting previously unselected package liberror-perl.
Preparing to unpack .../liberror-perl_0.17025-1_all.deb ...
Unpacking liberror-perl (0.17025-1) ...
Selecting previously unselected package git-man.
Preparing to unpack .../git-man_1%3a2.17.1-1ubuntu0.9_all.deb ...
Unpacking git-man (1:2.17.1-1ubuntu0.9) ...
Selecting previously unselected package git.
Preparing to unpack .../git_1%3a2.17.1-1ubuntu0.9_amd64.deb ...
Unpacking git (1:2.17.1-1ubuntu0.9) ...
Setting up git-man (1:2.17.1-1ubuntu0.9) ...
Setting up less (487-0.1) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
Setting up liberror-perl (0.17025-1) ...
Setting up libcurl3-gnutls:amd64 (7.58.0-2ubuntu3.16) ...
Setting up git (1:2.17.1-1ubuntu0.9) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
1.解决: Linux – git: command not found
2. 安装git提示E: Package ‘git‘ has no installation candidate