gitgit-taggit-notes

Add tags / label to git commits


I have a branching strategy where I have a branch that represent each of my org. Now when working on a branch , we can have commits for a release or a hotfix correction etc... I want to be able to tag/ label a commit as "hotfix" and another as "R3.x" etc...to differentiate between them, so that I know when I need to move them to another branch , to select exactly those label as "R3.x" or the hotfixes.

For several releases we used a prefix in the name like "R3.x - description". But when a commit is not approved to be part of the release we can no more update the message (I do not want to rewrite my history with git rebase i). That's why I wanted a simpler way to label by commits or to categorise my commits for better search afterwards.

I need a sort of git tag but that can be applied on several commits not only on a unique one. That will allow me to filter them afterwards via git log.

We do this actually but using part of the name. But I wanted to know if there is a better alternatives.


Solution

  • The only other "sort of git tag" that you can actually apply on different commit is git notes:

    Adds, removes, or reads notes attached to objects, without touching the objects themselves.

    So no history modification.

    You can leave a note on the commits you want to flag.
    Since git log has the --notes option, you can then filter your commits with the --grep option:

    --grep:
    When --notes is in effect, the message from the notes is matched as if it were part of the log message.

    git log --pretty=oneline --notes --grep=<keyword>