Remove Orphaned Commits From History

I deleted a branch that was accidentally pushed to my bitbucket repo. After deleting the branches using `git push origin --delete BRANCH_NAME`, commits from the branch still show up in the BitBucket web UI under the commit history for "all branches". I would like to clean up the history so that these commits, which are no longer part of any branch, are not displayed.

The commits no longer appear to be part of the git repository (e.g. if I try to use `git show COMMIT_HASH` I get a "bad object" error, indicating no commit exists with that hash, yet these commits still show up in the Web UI)

Is this possible to purge these commits such that they no longer appear in BitBucket?

2 answers

Try running garbage collector 

git gc --aggressive --prune=now


This does not appear to be a problem in my local git repository, it only appears to be a problem in the BitBucket web UI. How would I push removal of commits to the origin repo?

Like 1 person likes this

The branch wasn't showing up when I pulled the repo locally, but when I used "git ls-remote" I was able to see the remote branch and delete it.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Thursday in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder :  #!/bin/bash source "$(dirname "$0")/" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables ROLLBAR_ACCESS_TOKEN...

189 views 0 12
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you