1

A pull request was merged in several days ago and we've decided that the whole thing needs to come out.

A few commits have been put in after this action and I'd like to keep those.

I've included a screenshot of my commit graph below. The commit in question that I'd like to remove is 19fdbd1.

I attempted to use git rebase 19fdbd1 to do this but it did not have the intended effect as the feature in question was still present. I most likely did this incorrectly though.

example

castis
  • 8,154
  • 4
  • 41
  • 63
  • You mean remove a commit from your commit history right? I am pretty sure you can't make a pull request disappear unless your `git` gui has specific commands / tools for that. (I'm speaking from my experience in GitHub) – gran_profaci Apr 08 '15 at 23:32
  • Correct, "remove merged pull request" is what i should have said. – castis Apr 08 '15 at 23:40
  • OK... Well, you can remove commits from your merged pull request by looking at the answer(s) below. From GUI's like Github, you can't make a Pull Request disappear. http://stackoverflow.com/questions/18318097/delete-a-closed-pull-request-from-github – gran_profaci Apr 08 '15 at 23:44

3 Answers3

2

git revert --interactive 19fdbd1

Now, in the vim or your editor terminal that comes up, next to 19fdbd1, put in :

squash 19fdbd1 COMMIT MESSAGE

Now, git push -f origin BRANCH_NAME

Boom... 19fdbd1 never existed.

However, if you want the rest of your commit id's to be exactly the same, you can't simply just remove 19fdbd1 directly, and you'll have to do :

git revert 19fdbd1

This creates a new commit that gets rid of 19fdbd1

And then simply git push origin BRANCH_NAME

Notice there is no -f here since we didn't rewrite the commit history, just removed the changes from one particular commit.

gran_profaci
  • 8,087
  • 15
  • 66
  • 99
1

Use git rebase -i instead to specify exactly how you want to remove the commit. (That said, this sounds more like a job for git revert.)

Stuart P. Bentley
  • 10,195
  • 10
  • 55
  • 84
0

I realize this is a very old post, but I have been digging around to see if this is possible in bitbucket - to delete a merged pull request, and it appears it is not, at least in the server version 7.17.5. I also tried to see if i could reopen it to then delete it, and that didnt work either. There may be a way to do this in the internal database, but that could be playing with fire - obviously not an option for cloud hosted SCMs.

  • If you have a new question, please ask it by clicking the [Ask Question](https://stackoverflow.com/questions/ask) button. Include a link to this question if it helps provide context. - [From Review](/review/late-answers/34687316) – user12256545 Jul 17 '23 at 18:28