Git - 如何验证Ubuntu上是否安装Git以及在何处安装Git

Nas*_*ash 27 git ubuntu

我是Ubuntu和Git的新手.我如何验证我在我的机器上安装了git?当我尝试apt-get时,我得到了:

root@ubuntu:/home/nebojsa# apt-get install git
Reading package lists... Done
Building dependency tree       
Reading state information... Done
git is already the newest version.
The following packages were automatically installed and are no longer required:
  linux-headers-3.13.0-24 linux-headers-3.13.0-24-generic
  linux-headers-3.13.0-39 linux-headers-3.13.0-39-generic
  linux-headers-3.13.0-40 linux-headers-3.13.0-40-generic
  linux-headers-3.13.0-43 linux-headers-3.13.0-43-generic
  linux-image-3.13.0-24-generic linux-image-3.13.0-39-generic
  linux-image-3.13.0-40-generic linux-image-3.13.0-43-generic
  linux-image-extra-3.13.0-24-generic linux-image-extra-3.13.0-39-generic
  linux-image-extra-3.13.0-40-generic linux-image-extra-3.13.0-43-generic
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 133 not upgraded.
Run Code Online (Sandbox Code Playgroud)

但我不知道安装的软件包在哪里.

谢谢你的帮助!

Kev*_*ert 47

类型which git.它应该返回可执行文件的路径

如果您想了解更多详细信息:https://serverfault.com/questions/96964/list-of-files-installed-from-apt-package


小智 13

只需拨打电话git --version.它应该返回这样的东西:

$ git --version
git version 1.9.3 (Apple Git-50)
Run Code Online (Sandbox Code Playgroud)


Kei*_*son 7

像大多数可执行文件一样,git安装在/usr/bin/git.

要查看包中所有文件的git位置,可以键入:

dpkg -L git
Run Code Online (Sandbox Code Playgroud)

你想要输出输出less或你最喜欢的页面; 我的系统上有591 664行输出.

(并非所有的系统使用Ubuntu的做同样的包管理器,您可能需要使用比其他一些命令dpkg,也许rpm,yumdnf).

如果您从源代码而不是通过软件包管理器安装了git,git则可执行文件可以在任何位置,具体取决于您的安装方式.如果它在你的$PATH,打字

type git
Run Code Online (Sandbox Code Playgroud)

要么

type -a git
Run Code Online (Sandbox Code Playgroud)

会告诉你它在哪里.(假设你正在使用默认的bash shell.)