7

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.

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.

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

NinGen ShinRa
  • 651
  • 5
  • 16

1 Answers1

0

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

  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)

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

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

Waterlink
  • 2,239
  • 1
  • 17
  • 27