【问题标题】:Git tag message template?Git标签消息模板?
【发布时间】:2020-09-28 20:55:41
【问题描述】:

有没有办法设置git tag 消息模板,类似于提交消息模板的工作方式?

使用git config,我们可以为提交配置一个模板,指向一些.git-msg-template。例如,在~/.gitconfig 中,这将如下所示:

[commit]
  template = ~/.git-msg-template

但是,如果您通读 git 文档或只是在终端中查找git config tag.* 选项,似乎没有git config tag.template,只有git config commit.template 设置。

尽管如此,即使没有设置自定义 commit.template,提交和标签的默认消息对我来说也是不同的。提交以Please enter the commit message ... 开头,添加分支信息等等,而标签只有Write a message for tag: v1.0.0。因此,在内部,提交和标签应该有不同的模板?!

【问题讨论】:

    标签: git templates tags config


    【解决方案1】:

    git tag 没有模板文件选项;模板是hard coded into the Git source。但是,有一个 -F 参数可以从文件中读取消息。请注意git tag -mgit tag -F 将跳过运行编辑器,除非您还添加--edit。因此,您可以获得所需的效果:

    git tag --edit -F ~/.git-tag-template
    

    (我怀疑添加模板文件配置到git tag 的补丁,其代码类似于builtin/commit.c 中的代码。)

    【讨论】:

      猜你喜欢
      • 2013-05-18
      • 1970-01-01
      • 2022-09-22
      • 2014-02-28
      • 2015-10-30
      • 2012-08-26
      • 1970-01-01
      • 2019-09-21
      • 2011-08-25
      相关资源
      最近更新 更多