- TL;DR- How can I make my previous commits invisible on a repository which was once private and is now public?
So, I was one day working on a project which was on my private repo, after when I was done I made it public but my commits are visible to others and some threating information is also being leaked. So I had to make it private again. Please help me out to sort it, I'm still learning.
Tried Googling but results we irravenat and steps were too complicated.
You'll need to rewrite your branch history, which may break a lot of things.
To rewrite history, use rebase:
Then:
git-rebase-todofilegit addthe file with the oopsiegit rebase --continueand wait for it to finish.When it finishes, you'll have a differing branch history that doesn't commit an oopsie.
Caveats (there are many)
Same goes with tags:
If your branch contains merges, they'll effectively be flattened into a linear git history, and any conflict resolutions will need to be re-done. There is a way to preserve merges during
rebase, but I've not gotten it to work very well.Your name will be the committer on all the commits after
<commit-hash-with-the-oopsie>. The commit date will also change.The commit can persist in
.packfiles inside the git objects directory until anything that references it is more than 2 weeks old and you rungit gc. You can force git's hand in this usinggit reflog expire --stale-fix --expire-unreachable=now --all --rewrite && git gc --aggressive && git prune