We use gitlab issues at work, which supports tagging commit messages with an issue number, to make that commit appear in the issue thread. I often forget to tag my messages though, and then remember a second after committing.
So I wrote a little helper function as a custom git command:
OLD_MSG=$(git log --format=%B -n1)
git commit --amend -m "$OLD_MSG, #$1"
It’s just a simple shell script that fetches the last commit message and appends the issue number. So I can do this:
$ git commit -m "add css grid support"
# ah fuck, forgot that this is related to an issue!
$ git append-issue 27
# commit msg is now: "add css grid support, #27"
To make it work:
- Name the shell script
- save it in a folder in your home directory, i.e.
- make it executable with
- add that folder to your
- git now recognizes your custom command!
No webmentions yet.