Git - 如何验证 Git 是否以及安装在 Ubuntu 上的位置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28819345/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 02:58:42  来源:igfitidea点击:

Git - how to verify if and where Git is installed on Ubuntu

gitubuntu

提问by Nash

I am new to Ubuntu and Git. How I can verify that I have installed git on my machine? When I tried apt-get I got:

我是 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.

but I don't know where are the packages installed.

但我不知道安装包在哪里。

Thanks for your help!

谢谢你的帮助!

回答by Kevin Seifert

Type which git. It should return the path to the executable

键入which git。它应该返回可执行文件的路径

If you want to see more details: https://serverfault.com/questions/96964/list-of-files-installed-from-apt-package

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

回答by curlybracket

Just call the git --version. It should return something like this:

只需调用git --version. 它应该返回如下内容:

$ git --version
git version 1.9.3 (Apple Git-50)

回答by Keith Thompson

Like most executables, gitis installed in /usr/bin/git.

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

To see where all the files that are part of the gitpackage are located, you can type:

要查看属于git包的所有文件所在的位置,您可以键入:

dpkg -L git

You'll want to pipe the output through lessor your favorite page; I get 591664 lines of output on my system.

您将希望通过管道less或您喜欢的页面输出;我的系统上有591664 行输出。

(Not all systems use the same package manager that Ubuntu does. You might need to use some command other than dpkg, perhaps rpm, yumor dnf.)

(并非所有系统都使用与 Ubuntu 相同的包管理器。您可能需要使用除dpkgrpmyum或之外的其他命令dnf。)

If you had installed git from source rather than via the package manager, the gitexecutable could be anywhere, depending on how you installed it. If it's in your $PATH, typing

如果您是从源代码而不是通过包管理器安装 git,git则可执行文件可以在任何地方,具体取决于您的安装方式。如果它在您的 中$PATH,请输入

type git

or

或者

type -a git

would tell you where it is. (That's assuming you're using the default bash shell.)

会告诉你它在哪里。(假设您使用的是默认的 bash shell。)

回答by TEDDY

which gitis the command to use , this gives the location where git is installed if it is already installed , usually /usr/bin/git.If git isn't installed u wont be getting any thing.when git is already installed

which git是要使用的命令,/usr/bin/git如果 git已经安装,这给出了安装 git 的位置,通常是 。如果没有安装 git,你不会得到任何东西。当 git 已经安装时

回答by Messa

It tells you

它告诉你

git is already the newest version.

so everything should be OK.

所以一切都应该没问题。

Tip: to see files installed by a package, run

提示:要查看包安装的文件,请运行

dpkg -L git

It will list a lot of files, but the most important one is /usr/bin/git. Another command, which git, returns what file exactly is being run when you run git- it should be the same.

它会列出很多文件,但最重要的是/usr/bin/git. 另一个命令 ,which git返回运行时确切运行的文件git- 它应该是相同的。

回答by Kaur

Yup, git is installed. As for your question about the location of the package, this is most likely rather irrelevant for you. If you find yourself browsing a linux filesystem just to execute a program that has been installed system-wide, something is off. You don't usually need to do that at all.

是的,安装了 git。至于您关于包裹位置的问题,这很可能与您无关。如果您发现自己浏览 linux 文件系统只是为了执行已在系统范围内安装的程序,那么就有些不对劲了。您通常根本不需要这样做。

As for git, opening the terminal and typing 'git' will give you the basics. More can be read typing 'man git' (man command is good for finding additional info on a package).

至于 git,打开终端并输入 'git' 将为您提供基础知识。输入“man git”可以阅读更多内容(man 命令有助于查找有关包的其他信息)。

If you want a graphical front-end for git, see this https://askubuntu.com/questions/227554/what-are-some-gui-clients-for-git

如果您想要 git 的图形前端,请参阅此https://askubuntu.com/questions/227554/what-are-some-gui-clients-for-git