Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Bitbucket - How can I rename a branch that has already been merged?

Jamie Maiquez
Contributor
November 11, 2024

The wrong Jira Key is in the branch name and now it is linked to the wrong Jira. The branch has already been merged into main. Is there a way to rename that branch so that the Jira is referring to the correct branch?

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 13, 2024

Hi Jamie,

Yes, this is possible.

Assuming that the branch is named TEST-16-branch and you want to rename it to TEST-17-branch, you can do the following:

1. Clone the Bitbucket repository

2. Navigate to the directory of the clone, and checkout TEST-16-branch with the command:

git checkout TEST-16-branch

3. Rename the branch with the command:

git branch -m TEST-17-branch

4. Push the renamed branch to the Bitbucket repo:

git push origin TEST-17-branch

5. Delete the remote branch TEST-16-branch:

git push origin --delete TEST-16-branch

The renamed branch TEST-17-branch should now be referenced in the Jira issue TEST-17, and the deleted branch TEST-16-branch should no longer be referenced in the Jira issue TEST-16.

Please feel free to let me know how it goes and if you have any questions!

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin Site Admin
TAGS
AUG Leaders

Atlassian Community Events