git 指定版本号缩写长度 设置变量core.abbrev

在旧版本的git,git commit id 缩写默认为7位,用git log --oneline命令以缩写hash打印出git日志。

但是如果是庞大的项目,7位的hash其实很容易重复,有兴趣可以参考–How short can Git abbreviate

目前用的新版本git为2.17.1,git commit id 缩写默认为12位,但是又只想兼容旧版本,用7位hash怎么办?
在这里插入图片描述

参考git文档 core.abbrev

core.abbrev
Set the length object names are abbreviated to. If unspecified or set to “auto”, an appropriate value is computed based on the approximate number of packed objects in your repository, which hopefully is enough for abbreviated object names to stay unique for some time. If set to “no”, no abbreviation is made and the object names are shown in their full length. The minimum length is 4.

设置长度对象名称的缩写。如果未指定或设置为“自动”,则根据存储库中打包对象的大致数量计算适当的值,希望这足以让缩写的对象名称在一段时间内保持唯一。如果设置为“no”,则不进行缩写,并且对象名称以其完整长度显示。最小长度为 4。

git config core.abbrev 7配置这个变量,便可指定git commit id 缩写长度为7位。
在这里插入图片描述

参考文章- -Show commit size in git log

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值