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?

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

30,769 views 26 12
Join discussion

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