Git

rev-parse简介

git-rev-parse - Pick out and massage parameters
简单来说,rev-parse 是为了底层操作而不是日常操作设计的Git 探测工具(Plumbing Commands),可以查看 Git 现在到底处于什么状态。
换而言之,git rev-parse用于查看参数,返回结果通常可以直接使用不需额外处理。
 

一些命令

git rev-parse --help                   # 显示git rev-parse命令的帮助信息


git rev-parse --symbolic --branches    # 显示分支
git rev-parse --symbolic --tags        # 显示里程碑


git rev-parse HEAD                     # 显示HEAD提交的commit id
git rev-parse --short HEAD             # 显示HEAD提交的short commit id
git rev-parse <short commit id>        # 显示指定提交号的commit id


git rev-parse --branches                 # Printing SHA1 hashes of branches
git rev-parse --tags                     # Printing SHA1 hashes of tags


git rev-parse --local-env-vars         # 显示本地库的git环境变量名称
git rev-parse --git-common-dir         # 展示GIT_COMMON_DIR变量定义的值,如果没有定义则展示GIT_DIR变量的值


git rev-parse --is-inside-git-dir      # Checking if you're currently within a repository
git rev-parse --is-inside-work-tree    # Checking if you're currently within a work-tree


git rev-parse --git-dir                # 显示版本库.git命令所在的位置
git rev-parse --show-toplevel          # 显示工作区根目录,执行命令 
git rev-parse --show-prefix            # 显示相对于工作区根目录的相对路径
git rev-parse --show-cdup              # 显示从当前目录(cd)后退(up)到工作区的根目录的深度
原文地址:https://www.cnblogs.com/anliven/p/9305899.html