赞
踩
DH207891+OuyangPeng@DH207891 MINGW32 /d/git test
$ mkdir demo
DH207891+OuyangPeng@DH207891 MINGW32 /d/git test
$ cd demo/
DH207891+OuyangPeng@DH207891 MINGW32 /d/git test/demo
$ git init
Initialized empty Git repository in D:/git test/demo/.git/
DH207891+OuyangPeng@DH207891 MINGW32 /d/git test/demo (master)
$ echo "hello ." > welcome.txt
DH207891+OuyangPeng@DH207891 MINGW32 /d/git test/demo (master)
$ ll
total 1
-rw-r--r-- 1 DH207891+OuyangPeng 197609 8 6月 13 08:45 welcome.txt
DH207891+OuyangPeng@DH207891 MINGW32 /d/git test/demo (master)
$ git add welcome.txt
warning: LF will be replaced by CRLF in welcome.txt.
The file will have its original line endings in your working directory.
DH207891+OuyangPeng@DH207891 MINGW32 /d/git test/demo (master)
$ git st
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: welcome.txt
DH207891+OuyangPeng@DH207891 MINGW32 /d/git test/demo (master)
$ git ci -m "Initialized"
[master (root-commit) 89c9fa6] Initialized
1 file changed, 1 insertion(+)
create mode 100644 welcome.txt
DH207891+OuyangPeng@DH207891 MINGW32 /d/git test/demo (master)
$ git log
commit 89c9fa626e7d56c686e904ba34b8e21e9aaf43d8
Author: ouyangpeng <oypcz@foxmail.com>
Date: Tue Jun 13 08:46:17 2017 +0800
Initialized
DH207891+OuyangPeng@DH207891 MINGW32 /d/git test/demo (master)
$ mkdir -p a/b/c
DH207891+OuyangPeng@DH207891 MINGW32 /d/git test/demo (master)
$ cd a/b/c/
DH207891+OuyangPeng@DH207891 MINGW32 /d/git test/demo/a/b/c (master)
$ pwd
/d/git test/demo/a/b/c
显示版本库.git命令所在的位置,执行命令 git rev-parse --git-dir
DH207891+OuyangPeng@DH207891 MINGW32 /d/git test/demo/a/b/c (master)
$ git rev-parse --git-dir
D:/git test/demo/.git
显示工作区根目录,执行命令 git rev-parse --show-toplevel
DH207891+OuyangPeng@DH207891 MINGW32 /d/git test/demo/a/b/c (master)
$ git rev-parse --show-toplevel
D:/git test/demo
显示相对于工作区根目录的相对路径,执行命令 git rev-parse --show-prefix
DH207891+OuyangPeng@DH207891 MINGW32 /d/git test/demo/a/b/c (master)
$ git rev-parse --show-prefix
a/b/c/
显示从当前目录(cd)后退(up)到工作区的根目录的深度,执行命令 git rev-parse --show-cdup
DH207891+OuyangPeng@DH207891 MINGW32 /d/git test/demo/a/b/c (master)
$ git rev-parse --show-cdup
../../../
显示git环境变量列表的本地库,只列出变量的名称,而不是它们的值。执行命令git rev-parse --local-env-vars
DH207891+OuyangPeng@DH207891 MINGW32 /d/git test/demo/a/b/c (master)
$ git rev-parse --local-env-vars
GIT_ALTERNATE_OBJECT_DIRECTORIES
GIT_CONFIG
GIT_CONFIG_PARAMETERS
GIT_OBJECT_DIRECTORY
GIT_DIR
GIT_WORK_TREE
GIT_IMPLICIT_WORK_TREE
GIT_GRAFT_FILE
GIT_INDEX_FILE
GIT_NO_REPLACE_OBJECTS
GIT_REPLACE_REF_BASE
GIT_PREFIX
GIT_INTERNAL_SUPER_PREFIX
GIT_SHALLOW_FILE
GIT_COMMON_DIR
如果GIT_COMMON_DIR变量定义了则展示GIT_COMMON_DIR变量的值,不然则展示GIT_DIR变量的值
DH207891+OuyangPeng@DH207891 MINGW32 /d/git test/demo/a/b/c (master)
$ git rev-parse --git-common-dir
a/b/c/.git
显示分支,执行命令 git rev-parse --symbolic --branches
目前只有master一个分支,所以只显示master。
显示里程碑,执行命令 git rev-parse --symbolic --tags
DH207891+OuyangPeng@DH207891 MINGW32 /d/git test/demo/a/b/c (master)
$ git rev-parse --symbolic --tags
目前还未建立TAG,所以没有值显示。
显示HEAD提交的SHA1值,执行命令git rev-parse HEAD
,如下所示,先执行git log
命令查看提交记录,再执行命令git rev-parse HEAD
DH207891+OuyangPeng@DH207891 MINGW32 /d/git test/demo/a/b/c (master)
$ git log
commit 89c9fa626e7d56c686e904ba34b8e21e9aaf43d8
Author: ouyangpeng <oypcz@foxmail.com>
Date: Tue Jun 13 08:46:17 2017 +0800
Initialized
DH207891+OuyangPeng@DH207891 MINGW32 /d/git test/demo/a/b/c (master)
$ git rev-parse HEAD
89c9fa626e7d56c686e904ba34b8e21e9aaf43d8
git rev-parse命令还有很多种用法,大家可以使用git rev-parse --help
命令打开帮助文档,
或者打开 在线文档 https://www.kernel.org/pub/software/scm/git/docs/git-rev-parse.html
作者:欧阳鹏 欢迎转载,与人分享是进步的源泉!
转载请保留原文地址:http://blog.csdn.net/ouyang_peng/article/details/72903221
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。