Reputation: 3854
So I made a mistake and pushed some sensitive not for public information to github.
After realizing my mistake, I removed the information, re-committed and pushed again.
Then to remove it from git commit history, I rewrote my commit history using git rebase
and force pushed it to the remote.
Now I have a question, is there any way that data could be extracted from within the .git
folder? Keep in mind, the remote repository is public.
Upvotes: 1
Views: 122
Reputation: 11022
Every commit is stored in the git repository, even removed. You can see them with:
git reflog show
You can then checkout a commit with this reflog
command.
See this documentation: https://git-scm.com/docs/git-reflog
However, a git gc
can permanently remove unreferenced commit/files.
Upvotes: 3
Reputation: 142064
The simple answer is yes. You can retrieve any information stored under the .git
folder.
Read this detailed answer on how to do it: How to move HEAD back to a previous location? (Detached head)
In general: As long as the commits are stored in your .git
folder they can be "recovered" in different ways. If you want to "remove" then from the .git
folder you have to "clean" you repository.
# remove any old data not related to any commit
git gc --aggressive --prune=now
# Check and verify that all the objects in the repository are committed
# and print out a list of all the loose (dangling) objects
git fsck --full
Upvotes: 0