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

Delete a Pull Request

Michael Minton
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 12, 2012

How can I delete a Pull Request from the system completely?

If I have to do this manually I'm OK with that. We do not use an external database.

15 answers

2 accepted

6 votes
Answer accepted
Christian Glockner
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 8, 2017

Starting with Bitbucket 5.1, which is available now, you can delete pull requests. 

Wesley Miaw
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 8, 2017

Yay! Finally.

Like Roman Levkovich likes this
James Woodley
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 5, 2017

Can we not do this on bitbucket.org yet? I've got a list of declined PRs I'd love to delete.

 

All I have is the Approve button?

Like # people like this
stephen
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 25, 2017

Delete the PR from where exactly? All I see is an approve or decline button

Like # people like this
arnileibovits
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 12, 2018

Where is the "Delete" button on bitbucket.org?

Like # people like this
Weldon Sams
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 19, 2018

Is there a way to delete a merged pull request? I see how to delete one beforehand, but I have a critical need to delete a merged pull request asap. Thanks

pogpog
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 20, 2018

@Christian Glockner Thanks, but how?

Like Carlos Vigil likes this
Weldon Sams
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 20, 2018

@Christian Glockner, to the right of the merge button there are 3 dots. Under that menu you should have a delete option if you have permission to delete.

Screen Shot 2018-06-20 at 10.18.13.png

Like # people like this
Drew
Contributor
October 23, 2018

+1 for needing this on Bitbucket Cloud!

Like # people like this
pogpog
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 24, 2018

Yeah, need this on cloud

Like # people like this
Marco Budiongan
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 4, 2018

Hi I am also looking for that button to Delete PR. Was it moved recently? I'm not seeing the Delete button.

Screenshot from 2018-11-04 21-08-34.png

Like # people like this
Suman Koirala
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 26, 2019

Just Decline it and that will cancel the PR

Like # people like this
Stephen Brooks
Contributor
April 28, 2019

@suman to decline a PR is an action which states it is not accepted, there is the scenario when you may want to delete a PR because it was created unintentionally or otherwise. Therefore decline and delete are separate actions.

Like # people like this
Sean Hansford
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 25, 2019

To the cloud!

Like # people like this
Alex Pereira
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 11, 2019

Quando teremos no bitbucket cloud?

Olga Svyryd
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 31, 2023

My congratulations, you did it! I have just deleted my obsolete PR and dont have  proper words to THANK YOU! 

2 votes
Answer accepted
seb
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 13, 2012

Pull requests cannot be deleted. You could tinker with the database but I would highly recommend against it (we could not provide you with adequate support if something goes wrong).

Why do you want to delete pull requests?

Michael Minton
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 19, 2012

Pull request submitted for testing purposes will remain forever. Not a huge deal I suppose.

John McIntosh
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 16, 2013

I, too, would really like to have the ability to delete declined pull requests. We work on a team of several developers, and our workflow is that pull requests in the Open tab are ready to be reviewed. If changes need to be made, the PR is declined and re-opened when changes are ready for review again. However, there are many times that for whatever reason a branch that was once reviewed gets abondoned. Now, that branch is permananatly sitting in the Declined box, so that box can no longer be treated as a list of open issues that still need work. It would be a huge help to be able to permanantly delete items from there.

Avelino Alicea
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 1, 2016

"Why do you want to delete pull requests?"

Because it is referencing a ticket that is not related to the change. I, as a release Engineer, run into this issue often when developers commit work and push to the wrong branch and then reference another branch and ticket they thought they were working on. Since I can't delete the pull request, the reference stays and the tickets appear to be linked even though they aren't linked or related.

Like r.prosenc likes this
Ryan Elisei
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 15, 2016

Here's another reason: The PR contained credentials. Not only do I want to be able to decline the PR, I want the history of the PR gone as well.

Like # people like this
Adam
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 15, 2016

I don't want to misinform, but I believe you should be able to to remove the commit from any branches, decline the PR, and force a git gc to remove the data from BBS. The specifics on how to force the git gc might be more involved - for example you might need to be sure that the commit is no longer in the reflog (which is like Git's recent history of previous commits that a ref pointed to) before git gc will remove the commit. Don't take my word for it though - someone else might be able to comment more authoritatively, or you can probably get better help at support.atlassian.com. I don't want you to break your instance by following my instructions in production, so definitely test it out somewhere non-production and take a backup first (which you might later have to delete if you really want those credentials gone).

All that said - once credentials are compromised, you should definitely stop using them and change the password, regardless of whether you can successfully remove them from the repository. They've been leaked and aren't secure anymore. If you do this, it also makes their removal from the repo less important as well since the credentials are no longer valid. Of course if the leaked data is "names and addresses of all our customers" and not credentials, this suggestion doesn't help - can't change those.

Best of luck, Ryan. Don't hesitate to get help from support if you need it.

Adam

Ryan Elisei
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 16, 2016

People have commented more authoritatively - check out the threads below. You cannot delete PRs even after they're declined.

codelab23
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 20, 2018

It's fine :) 

Stephen Brooks
Contributor
November 19, 2018

"Why do you want to delete pull requests?"

Why do you not provide the option so that users can manage there workflows as they chose? 

Like # people like this
Jessy Houle December 27, 2022

Well said

54 votes
Jonathan Holmes
Contributor
March 18, 2014

I think deleting a pull request is a valid use case. We had an issue where a developer accidently commited a file with sensitive information, and submitted a pull request where that information was visibile to all. It now lives on in a pull request, and we have no way of removing this.

Wesley Miaw
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 7, 2014

Another vote for this.

Alexandre Rio
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 13, 2016

What about pushing another commit on the concerned branch removing the file with sensitive information ?

Dmytro Pylypenko
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 24, 2017

override pull request to upstream by creating on it new commit(for example with --amend) and `git push -f`. It will decline pull request, at least I don't have any requests for it after this action.

8 votes
Greg Kogut
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 28, 2013

x2. I just created a pull request, and accidentally picked the wrong destination branch. I apparently can't edit the request to pick the right branch or delete the whole request. My mistaken request will exist forever as clutter.

Adam
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 28, 2013

In newer Stash versions you can change the destination branch if that helps. :)

John McIntosh
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 28, 2013

It does help -- I was glad to see that added recently! That said, I'd still love to be able to permanently delete some declinced PRs. In our project with 12 devs, we're now up to about 100 declined PRs that will live in the declined box forever. A handful of those were from before you could change the destination branch after creating a PR, but most are ideas that were started and reviewed, but for one reason or another were declined/abandoned. Would be really nice to have the ability to let Declined tab function as a list of PRs that have not passed code review, but are still actively being worked on. It's easy for them to get lost in the noise as it is now.

Like r.prosenc likes this
Bill Masek
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 23, 2014

While that helps, I already merged those changes into an alternate branch and now I cannot reset the branch to that branch. Deleting a pull request is a very important feature. People make mistakes, requirements change and others can come up with a much better approach.

Like # people like this
4 votes
Charles Pikscher
Contributor
May 24, 2019

With the latest BB, you can delete an Open or Declined Pull Request. But not a Merged Pull Request.

I recent had a user commit sensitive data and then merged a Pull Request. Even after removing all references to the commit, it would not go away. I think this is because it was referenced by the PR. 

I finally got the commit to be gc'd by deleting the stash-refs/pull-requests/N directory from the server. Then the commit was able to be pruned by git-gc on the server. 

The PR still existed, but it wasn't able to show the commits or diff anymore. It did show an infinite loading circle, but that's okay. The sensitive data is gone. 

I understand not wanting to delete Merged PRs, but it seems like you should at least allow the System Admin to do this. 

3 votes
LifeOfAFlippedTable
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 30, 2015

Hi All, 


There is a Hot existing request on this which you can find it on STASH-3134. Please watch that ticket for the development progress of this feature.

 

Cheers, 

Andrew Er

2 votes
abhishek-alai
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 13, 2019

Our team is on Bitbucket.org using a paid plan. I think we SHOULD be able to DELETE a PR. But I don't see a button anywhere. 😐

1 vote
Tom Chamberlain April 26, 2017

If you click Decline, and you are the author, it will close the PR

Alex Kwiatkowski
Contributor
April 26, 2017

Hi Tom, closing is not the issue. Declined pull requests remain in the system and can be found in the "Declined" group. Declined pull requests behave the same whether it was the author that declined them or not.

Like # people like this
0 votes
Sairam Katla
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 29, 2021

you can use 'Decline' option in PR page. and Delete it.Screen Shot 2021-06-29 at 3.19.10 PM.png

arnileibovits
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 30, 2021

How do you delete a Declined PR? Deleting the branch does not delete the PR.

0 votes
arao
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 27, 2019

Sorry should have been more clear. Declining is what you do for the PR, then delete the branch.

0 votes
Jong-hoon Oh
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 13, 2019

Could be a dangerous hack, but I found that pull request data is located at table `sta_pull_request` within the database, with it's `id` column mapped as foreign keys on other tables with `on delete cascade` except for table `sta_pr_activity`.

So you can (at your own risk. always backup!) remove the undesired merged pull request record from the list by

a) find the row from `sta_pull_request` to be deleted
b) remove rows from `sta_pr_activity` with `pr_id` column matching row id found from above
c) remove row from `sta_pull_request`

Then you could also apply git pruning described above by @Charles Pikscher 

0 votes
Steve Simpson
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 11, 2019

What about ISO 9001?  I'd like to have the ability to mark PR's as not deletable for traceability.  The review comments help explain why something was added, removed, modified.  Without that you're relying on commit messages.

0 votes
aditigidra August 16, 2018

Is this option available for Bitbucket server 5.9.3?

0 votes
Deleted user April 16, 2018

heres a quick py script to delete both Pull Requests and Branches from a given repository,

 

all the necessary API calls are in the script,

https://gist.github.com/perfecto25/633170c049ad1db8fdf5165a2fcf7171

0 votes
Alex Kwiatkowski
Contributor
August 27, 2015

+1

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events