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')
BFG Repo cleaner is an alternative to git filter-branch. It can be used to remove sensitive data or large files that were committed wrongly like binaries compiled from the source. It is written in Scala. Project website: BFG Repo Cleaner.
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
.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With