首页 > 其他分享 >git 命令行获取信息

git 命令行获取信息

时间:2022-11-02 16:24:54浏览次数:55  
标签:git 提交 做者 日期 获取信息 命令行 commit 提交者

获取某个commit的信息:git

$ git log --pretty=format:“%an” HEAD -1
“auto”

获取某个commit的时间:bash

git log --pretty=format:“%cd” HEAD -1
“Wed Apr 3 10:12:33 2019 +0800”

获取某个commit的提交message:app

$ git log --pretty=format:“%s” HEAD -1
“xxxxxxxxxxxxxxxxx.”

其中--pretty=format:“%xx”能够指定须要的信息,其经常使用的选项有:ui

%H 提交对象(commit)的完整哈希字串 
%h 提交对象的简短哈希字串 
%T 树对象(tree)的完整哈希字串 
%t 树对象的简短哈希字串 
%P 父对象(parent)的完整哈希字串 
%p 父对象的简短哈希字串 
%an 做者(author)的名字 
%ae 做者的电子邮件地址 
%ad 做者修订日期(能够用 -date= 选项定制格式) 
%ar 做者修订日期,按多久之前的方式显示 
%cn 提交者(committer)的名字 
%ce 提交者的电子邮件地址 
%cd 提交日期 
%cr 提交日期,按多久之前的方式显示 
%s 提交说明
%H: commit hash
%h: 缩短的commit hash
%T: tree hash
%t: 缩短的 tree hash
%P: parent hashes
%p: 缩短的 parent hashes
%an: 做者名字
%aN: mailmap的做者名字 (.mailmap对应,详情参照git-shortlog(1)或者git-blame(1))
%ae: 做者邮箱
%aE: 做者邮箱 (.mailmap对应,详情参照git-shortlog(1)或者git-blame(1))
%ad: 日期 (--date= 制定的格式)
%aD: 日期, RFC2822格式
%ar: 日期, 相对格式(1 day ago)
%at: 日期, UNIX timestamp
%ai: 日期, ISO 8601 格式
%cn: 提交者名字
%cN: 提交者名字 (.mailmap对应,详情参照git-shortlog(1)或者git-blame(1))
%ce: 提交者 email
%cE: 提交者 email (.mailmap对应,详情参照git-shortlog(1)或者git-blame(1))
%cd: 提交日期 (--date= 制定的格式)
%cD: 提交日期, RFC2822格式
%cr: 提交日期, 相对格式(1 day ago)
%ct: 提交日期, UNIX timestamp
%ci: 提交日期, ISO 8601 格式
%d: ref名称
%e: encoding
%s: commit信息标题
%f: sanitized subject line, suitable for a filename
%b: commit信息内容
%N: commit notes
%gD: reflog selector, e.g., refs/stash@{1}
%gd: shortened reflog selector, e.g., stash@{1}
%gs: reflog subject
%Cred: 切换到红色
%Cgreen: 切换到绿色
%Cblue: 切换到蓝色
%Creset: 重设颜色
%C(...): 制定颜色, as described in color.branch.* config option
%m: left, right or boundary mark
%n: 换行
%%: a raw %
%x00: print a byte from a hex code
%w([[,[,]]]): switch line wrapping, like the -w option of git-shortlog(1).

标签:git,提交,做者,日期,获取信息,命令行,commit,提交者
From: https://www.cnblogs.com/caimagic/p/16851397.html

相关文章

  • Git报错:Another git process seems to be running in this repository 解决方法
    Unabletocreate‘D:/xxx/.git/index.lock’:Fileexists.Anothergitprocessseemstoberunninginthisrepository,e.g.aneditoropenedby‘gitcommit’.......
  • github私有仓库连接,拉取代码
      在图中显示的日期后就不能用用户名,密码登录在用户设置里面,生成自己的tokens,只能看到一次  gitinit初始化仓库gitremoteaddorigin仓库http地址gitrem......
  • 利用node创建命令行工具
    什么是命令行工具?命令行工具(CmmandLineInterface)简称cli,顾名思义就是在命令行终端中使用的工具。我们常用的git、npm、vim等都是cli工具,比如我们可以通过gitclo......
  • git远端分支合并错误,需要回退到之前的分支
    工作中经常遇到gitcommit后(尚未gitpush操作),需要回退的情况具体方法如下:1.执行gitlog找到本次commi的ID信息比如commitid信息为:90f1ce4d73c5dc63f46fa61984a6bb878f47......
  • GIT常用指令
    拷贝项目代码gitclone+项目地址新建、切换分支gitbranch-a 查看已有的分支gitswitchmain 切换到要拉取的代码分支(从main分支拉取,也从main分支更新......
  • .gitignore模板
    #customBiomind-Utils/*.log.*temp/*.tar*.zip*_temp/Miniconda3-4.5.12-Linux-x86_64.sh*.code-workspace*.built_tempfile*.ndpi*.idea.vscode/node_mod......
  • Git & Linux
    Git资源下载技巧:所有需要外网下载的资源可以去找对应的国内镜像进行下载。基本Linux命令学习cd改变目录cd..回退上一级cd进入默认目录pwd显示当前目录路径......
  • 有可能是学习Git命令最好的网站
    网站地址:https://learngitbranching.js.org/?locale=zh_CN网站以沙盒闯关的方式学习Git各个命令,每次关卡都介绍本次要学习的Git指令,通过沙盒+命令行的方式来引导你通过已......
  • Git
    Git简介最好的版本管理系统没有之一解决的问题代码的版本管理团队分工协作git常见命令gitconfig--globaluser.name“用户名”gitconfig--globaluser.email......
  • biogeme巢式logit选择学习
    #导入库```pythonimportpandasaspdimportcsvfrombiogemeimportmodelsimportbiogeme.biogemeasbioimportbiogeme.databaseasdbfrombiogeme.expressionsimpo......