I was trying to remove a couple of lines from a file in my history containing a secret API token and some endpoint that are way better passed as environment variables than hardcoded there, so if I make the repo public someday they won't be there for the indiscreet eyes.
I've used for this purpose the awesome tool that is the BFG repo cleaner, which I also used in the past to delete whole residual and sensitive files from my git history. This time following the instructions to replace text:
$ java -jar ~/bfg.jar --replace-text tokens.txt myRepo.git
But in the output, this appeared:
...
* commit 10134503 (protected by 'HEAD') - contains 1 dirty file :
- app.py (640 B)
...
If you *really* want this content gone, make a manual commit that removes it,
and then run the BFG on a fresh copy of your repo.
So I did exactly that, cloned the whole thing, made a commit replacing the two lines I wanted gone for 2 calls to os.environ[]
on python and pushed it. Then I ran again the BFG, git reflog
and everything seemed to worked like a charm.
I checked in gitlab's commit browser and the text was ***REMOVED***
everywhere but in the penultimate commit, where this happened:
I'm guessing it happened because the file is edited in next commit (now the one protected by 'HEAD') and GIT needs those tokens to recreate the changes I made to get rid of those 2 lines. But then, how do I achieve this?