如何找出我正在运行的 git 版本?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8475958/
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
How can I find out what version of git I'm running?
提问by Paul Sheldrake
I'm trying to follow some tutorials to learn how to use Git but some of the instructions are for specific versions.
我正在尝试按照一些教程来学习如何使用 Git,但其中一些说明是针对特定版本的。
Is there a command that I can use find out what version I have installed?
有没有我可以使用的命令找出我安装的版本?
回答by Gareth
$ git --version
git version 1.7.3.4
git help
and man git
both hint at the available arguments you can pass to the command-line tool
git help
并且man git
都提示您可以传递给命令行工具的可用参数
回答by Gnat
If you're using the command-line tools, running git --version
should give you the version number.
如果您使用命令行工具,运行git --version
应该会给您版本号。
回答by rachel
In a command prompt:
在命令提示符中:
$ git --version
回答by nawfal
Or even just
或者甚至只是
git version
Results in something like
结果类似于
git version 1.8.3.msysgit.0
git 版本 1.8.3.msysgit.0
回答by Lee Ikard
which git &> /dev/null || { echo >&2 "I require git but it's not installed. Aborting."; exit 1; }
echo "Git is installed."
That will echo "Git is installed" if it is, otherwise, it'll echo an error message. You can use this for scripts that use git
如果是,它将回显“Git is installed”,否则,它将回显错误消息。您可以将其用于使用 git 的脚本
It's also customizable, so you can change "which git" to "which java" or something, and change the error message.
它也是可定制的,因此您可以将“which git”更改为“which java”或其他内容,并更改错误消息。