Linking Git Commits to Jira Issues

 

 

To create a link between your Git commit and a Jira issue, developers must include the issue key into the commit comment.

For example, the “GIT-50 fixed issue” comment – this assumes that you have configured a Jira project with the key ‘GIT’ and someone has created the issue #50 within this project.

Commits are selected by issue key.  Developers should add them to comments every time the commits are made.

Git Commits tab example
Example Git commit message: “GIT-913 - Plugin version…”.  In this case, “GIT-913” is the issue key linking the commit message to the Jira issue.
warning
Commits that are part of non-master branches will be included only if the master branch doesn't have them.

As a best practice to work with subtask — put the parent and subtask Jira issue keys in the commit message so that the commit shows in both places.  This way, the commit for the subtask does not get lost in the many commits of the parent issue.

Commit association to both specific subtask and the parent issue

The Git Integration for Jira add-on supports commits that used the old Jira key in the commit message after a project rename to a new key name (Example: TEST1-16 to TEST-16).

There are two scenarios related to the rename/move:

  • The Jira project key was renamed and the commit message contains the old key prior to the installation of the Git add-on
  • The Jira issue was moved from one project to another project and the message contains the old key prior to the installation of the Git add-on

Manually Link Git Commits to Jira Issues Jira Cloud only

 

 

fyi
The process steps in this section only applies to Jira Cloud with installed Git Integration for Jira add-on.

To manually link a git commit to a Jira issue, access the Change commit issues feature from the following locations:

  • Project page > Git Commits > click View Full Commit.
  • Issue page > Git Commits tab > click View Full Commit.
  • Git menu > View all repositories > select a repository with git commits.

Click the Change commit issues label.  The following dialog is displayed:

change commit issues dialog showing blank entry

Add, edit or delete linked Jira issue keys in the Associated issues to commit field.

If the commit is associated with multiple Jira issues, you will see the following:

change commit issues dialog showing linked issues comma separated

In the above example, the selected commit is associated with Jira issues TEST-1, TEST-2 and PROJ-4 separated by commas.

Using the above example:

  • To associate the commit to an issue, insert a new issue key separated by a comma.
  • To remove commit association to an issue, delete the issue key.

Click Save to save the changes.

Git Notes

Starting v2.6.21, the Git add-on displays git notes in the Git Commits tab:

Actual git commit sample, git note

For a git repository with several existing commits in it, commit authors can associate issue keys via git notes to these commits without having to edit the commit messages.  The Git Integration for Jira add-on will index issue keys in git notes.

Smart commit actions are also supported in git notes.

Each commit can only have one git note per namespace.  There can be multiple note namespaces per commit.  These note namespaces are automatically indexed.

fyi
Git notes are sorted by name.

Guidelines for adding new git notes:

  • add git notes to new commits which has not been indexed yet;
  • git notes can be added to old commits which is already indexed - but does not have an issue key.
fyi
For old commits that are already indexed and have issue key(s) in commit message - see FAQ > Reindex > How do I clear the Git Integration Plugin for Jira cache manually? topic.

Adding a git note to an already reindexed commit:

git notes add -m 'TST-3 is also fixed' 107af254
git show -s 107af254
git push origin refs/notes/*