Skip to content

Best practice / How to link a git commit to issue (and back)?

I hope, this is okay, to place here a best practice question.

I didn't find much during my research.

I wonder, what is the best practice using GitLab to link a git commit to an issue. So you can identify in which context and why a certain change was made.

For example, if I've a look into the the history of this file: image

I just see, when it was created, by whom, which branches are using this commit. But I've no chance to identify the issue hence the context of this.

So I wonder, which options do I have:

  1. enforcing the issue id like mentioned in References in Commits and Code review and Push Rules
    • so I would have at least a chance get the issue number
  2. not deleting the merge request branches
    • does not solve this issue
    • would spam the branch view
    • not possible to create a second MR for an issue
    • but would allow to see all commits related to an issue

Or is there anything else native to link the git commits to issue, so they are also linked back and you can see also commits done in context of an issue like Jira or other tools allows it.

Which option do I have, and what is the best practice?

Edited by Michael Decker