35

When cleaning the repo with BFG (https://rtyley.github.io/bfg-repo-cleaner/) ,encountered the following :

Protected commits
-----------------

These are your protected commits, and so their contents will NOT be altered:

 * commit ******* (protected by 'HEAD')
0

3 Answers 3

59

Running BFG with: --no-blob-protection fixed it for me.

The docs are here: https://rtyley.github.io/bfg-repo-cleaner/, but I didn't see where they really call that out as a means to move past the error.

Note: In my case I had already tried to remove files manually, not using BFG, which got me in a state where I had to use --no-blob-protection.

0
14

If you're going to use a tool as powerful as BFG, I'd strongly advise you to read its documentation (which spells this out), but to answer your question:

BFG by default leaves "current" commits unchanged. Its author believes the only safe workflow is to clean up your repo's current state manually, test that everything still works, then use BFG to clean up history while leaving the current-state (which you already fixed manually) alone.

There are options available to change the protection from default (or turn it off) if you have use cases where you think it's unnecessary (as I have more often than not); but if you want to use those, you definitely need to read the docs.

1
  • 2
    @mike23 - 'git rm files-I-don't-want && git add . && git commit` May 7, 2019 at 12:55
3

This is a very late reply, but I hit a similar problem.

Were you trying to remove a file from a git repo and its history? Were you in a hurry and failed to notice that file is present in the state of the most recent commit, which BFG by default treats as protected? This was an error that happened between my keyboard and chair today.

If you want to clean a repo: (1) remove the unwanted file with the usual git commands e.g., git rm file; git commit, (2) test that everything still works without that file, (3) use bfg to rewrite the repo history without that file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.