Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Link already committed code in bitbucket repo to jira epics or user stories


We have committed code in bitbucket repo to one of our environments without any branching related to issues in jira. Is it possible to create branches or link those issues or user stories in jira matching with the already committed code for traceability purposes. Thanks

1 answer

0 votes

Hi @Ashlee and welcome to the community!

Regarding creating branches:

This depends on how your commit graph looks now and what you want to achieve.

Let's say there 3 commits that you want to link to Jira issues:

  • are they the latest 3 commits in the branch where you created them? Or are there more commits after them?
  • Are any of these 3 commits a merge commit?
  • And do you want to remove them completely from the branch they are now into a new branch, which you can later merge to the branch they are now?

Regarding linking Jira issues to existing commits:

It is possible to change the commit messages of the existing commits so that you add the corresponding Jira issue key in these messages (without creating or changing any branches).

Please note though that this process includes rewriting history, which means that the hashes of these commits (and commits after them) will change.

  • It would be good to communicate this to your team if you decide to do it, so everybody takes a fresh clone of the repo afterwards to avoid pushing the commits with the old hashes.
  • Please take a backup of the repo (a clone with the --mirror flag) in case anything goes wrong and you want to restore the repo to the previous state.

I would also recommend creating a fork of the repo to test the solution I am suggesting below and pushing the changes to the fork first, to inspect if it's in a good state before you push to the existing repo.

The process to change commits messages is the following:

1. If you want to change the commit messages e.g. of the 9th and 10th latest commits, you can run

git rebase -i HEAD~10

This command will display the latest 10 commits in your default text editor.

2. Move to the lines of the commits whose message you want to change, and replace the word pick with the word reword. Leave the other lines as they are, save the changes and close the editor.

3. Then, for each commit that you chose to reword in the previous step, a new text editor window will open.
In there, you can change the commit message of that specific commit and add the Jira issue key, save the changes and close the editor.

4. After you finish this process, you can run a git log to confirm that the commit messages have been changed to include the Jira issue keys.

5. You will need to push these changes with

git push --force <remoteName> <branchName>

since you have rewritten history.

Again, test this by pushing to a fork of the repo first, to inspect if the repo is in a good state after the push.

Make sure that no one has pushed any newer commits to that branch that you don't have locally, as they will get removed if you force push. 

If you have any questions, please feel free to let me know.

Kind regards,

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events