How to delete commits forever from bitbucket?

I have a set of commits (not belonging to any branch). I'd like to delete them, so that the commit history does not show them. Is this possible?

1 answer

1 accepted

0 votes
Accepted answer
Jason Worley Atlassian Team Sep 02, 2014

Hi Jason!

I would like to ask connecting to this question. I am able to remove commits of a branch via force pushing from a local repository, where I reseted the branch before it, and it works fine. However, I am still interested in what happens to the commit (at your side) after then? In the project news feed there is an entry about I uploaded a commit (which I then removed via force push), I can click the commit id, check the changes and even check the source for it.

So the commit itself is not included in any of our branches anymore. Is it kept being stored permanently anyways, and will I be able to check it anytime on the link given in the project news feed? Or are these floating commits get removed by time? Should I even care about those commits or how much space they occupy, or it is 100% irrelevant and  should I just let them be?

I look forward to your reply, have a nice day.

I have encountered the same problem. I suspect my problems began when I attempted to push and existing repo into my brand new repo, with:
  $ git clone --bare {RepoURL}/{ExistingRepo}.git
  $ cd {ExistingRepo}.git
  $ git push --mirror {RepoURL}/{MyNewRepo}.git

I didn't understand at the time that the bare and mirror options resulted in copying all branches and commits from the original repo.  What I wanted was just the files from the latest commit.  I learned that this is best done by doing a filesystem copy of those files, carefully avoiding the ".git" directories.

At this point the extra branches are deleted, and the old commits are cleared from my local repo log, but the old commits persist in the BitBucket. For example, on m up-to-date local the command:
   $ git log HEAD..remotes/origin/master
returns zero commits, but the BitBucket UI displays hundreds of them.

Hi @Jason Worley,

I second the question from Dávid Magyar as I noticed the same on BitBucket Self-Hosted on our side. I'm a bit concerned about this. Suppose you commit something sensitive in a commit and you'd like to get rid of it forever.

Although I actually "deleted" the commit through git, when I push the branch ( with --force or --force-with-lease ) the commit on the PR status is flagged as deleted, but if I click on the hash of the deleted commit, I can see the commit itself. Looks like to me that the hash is not really deleted on the repository then.

Suppose some malicious actor gets control of our Self-Hosted instance, can potentially scrape for this information and cause some harm.

What is your team related to Security doing about this? Is there something we can do about as well?

Thank you in advance,

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

1,905 views 7 10
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