If someone Git commits to the wrong Jira issue number, how do we fix it with Bitbucket and Jira so that commit/changeset becomes connected to only the correct Jira issue?
What's the best practice for this case?
Hi @eirens ,
A commit message in the repo can be changed by rewriting history (so you can replace the commit message with the wrong issue key with a message that has the correct issue key).
This process will create a new commit (with a new hash) that will replace the old commit (the old commit will then become a dangling commit in the repo). You will then need to force push these changes to the repo.
In Jira, the new commit will then appear in the new, correct Jira issue you reference.
However, the old commit will still show up in the wrong JIRA issue.
(This is if you use Jira Cloud, I am not sure about the behavior with Jira Server. Are you using Jira Cloud or Server?)
The reason for that is that Jira indexes referenced commits in its database.
When you rewrite history, you are essentially creating a new commit with a new hash (and the old one becomes a dangling commit) and the old commit (with the wrong Jira issue key) has already been indexed in the Jira database.
If you would consider rewriting history in the repo, I can reach out to the Jira team and ask whether it is possible to delete indexed data from the database and re-sync the repo, in case this would help to solve the issue of the old commit still showing in the wrong Jira issue. Please let me know whether you're using Jira Cloud or Jira Server, so I can reach out to the appropriate team.
Please note that it's essential to communicate to your team if you plan to rewrite history. Since the commit's hash will change, other users working on this repo will need to take a fresh clone, to avoid pushing back the old commit. Make sure you also take a full backup of the repo (clone it with the --mirror flag) before you force push any changes.
Feel free to also let me know if you'd like details on how you could rewrite history to change the commit message and also if you have any other questions.
Hi @eirens ,
Sure, I would just like to ask a few questions first, because I'm seeing different behavior with rewriting history, depending on the branch that the commit belongs to.
Could you please let me know:
1. Are you using more than one branch in this repo?
2. If so, does the commit with the wrong JIRA issue key exist in the main branch, or in a different branch?
3. In case it belongs to a different branch (other than the main one), has this branch been merged in either the main branch, or any other branch?
I'd like to reproduce your exact use case with rewriting, and let you know what the outcome would be before giving you any instructions.
I'll also check with Jira Cloud team whether a resync is possible.
Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events