标签提交将它们分组在Git中 [英] Labelling commits to group them in Git

查看:111
本文介绍了标签提交将它们分组在Git中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Git中是否有一种方法/常见做法来标记和分组提交?我了解,例如,<事实>惯例是指以散列号开头的问题编号和以符号开头(例如Fixed #23@userName)的人员,以及类似的应用程序. BitBucket或Github已经正确解析了这些.

Is there a way/common practice to label and group commits in Git? I understand that the de facto practice, for example, is to reference issue numbers preceded by an hash and people preceded by an at-sign (such as Fixed #23 or @userName), and applications like BitBucket or Github already parse these correctly.

我想对某种类型的提交进行分组,以便以后可以轻松地引用它们.例如,有时我实现了某些更改,但是我知道我迟早会对其进行修改:因此,我通常在提交消息中写入for the time being,因此对于我来说,仅搜索日志中的此类提交就更加容易.

I would like a way to group a certain type of commit so that I can easily reference them later. For example, sometimes I implement certain changes, but I know I'm going to modify them sooner or later: so I usually write for the time being in the commit message, so it is easier for me to just search the logs for such commits.

那么,在这些情况下,是否有一种常用或最佳的做法?甚至我不知道的git工具?

So, is there a way, common/best practice that is used in these cases? Or even a git tool I am not aware of?

推荐答案

您可以在存储库中使用post-commit挂钩来实现此效果.简要地:

You could use post-commit hooks in your repository to achieve this effect. Briefly:

  1. 您提交的消息带有特殊标签(例如:@fancy_label)
  2. post-commit钩子解析您的提交消息并检测到此@fancy_label(和其他标签)
  3. post-commit钩子,此钩子之后将此提交添加到每个标签的提交列表中,并将其保存到持久性存储中(保存到纯文件甚至数据库中)
  1. You commit with message, containing special label (example: @fancy_label)
  2. post-commit hook parsing your commit message and detects this @fancy_label (and other labels)
  3. post-commit hook after this adds this commit to list of commits for each label and saves it to persistent storage (to plain files, or even database)

此永久性存储可以是个人的(在.git文件夹中不可提交)或可提交的(在项目中包含).

This persistent storage could be personal (non-committable in folder .git) or committable (included in project).

并且您需要制作git别名,以使通过各自的标签搜索和列出此提交变得更加容易.

And you need to make git aliases to make searching and listing of this commits by their respective labels easier.

这篇关于标签提交将它们分组在Git中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆