How to link existing git branch to Jira ticket after creation

I’m working with Jira that’s integrated with our git repository. Usually when we start new work, we use the ‘create branch’ feature in Jira which automatically links the branch to the ticket. This makes it easy to see all commits related to that specific issue.

However, sometimes developers create branches directly in git without going through Jira first. Maybe they forgot about the ticket or started coding before the issue was created. Now I have a branch with commits but it’s not connected to the Jira ticket.

Is there a way to connect an already existing git branch to a Jira issue after the fact? I want to get the same tracking benefits as if I had used the ‘create branch’ button originally.

depends on your jira setup, but you can usually edit the branch desc in github/bitbucket and add the ticket key. some integrations let you link straight from the jira ticket - just click “link development” and paste your branch url. for future, include the ticket number in your commits and it’ll connect auto.

Easiest way? Just rename your branch to include the Jira ticket key. Use something like feature/PROJ-123-description and Jira will pick it up automatically. Run git branch -m new-branch-name then push the renamed branch. You can also check your integration settings in Bitbucket or GitHub - they usually let you link branches manually. Pro tip: if you’ve got the ticket number in your commit messages, renaming the branch will often connect everything automatically. Works on most setups.

If you can’t rename the branch because it’s already pushed and others are using it, just add the Jira ticket key to your commit messages. Use git commit --amend -m "PROJ-123: your commit message" for your latest commit, or git rebase -i to edit older ones. Most Jira integrations automatically scan commit messages and link tickets when they find references. You could also check if your repo hosting service lets you manually link branches to issues - GitLab and some others have this in their web interface. I’d go with the commit message approach though - it’s more reliable and the connection sticks around even if you do branch operations later.