We can recover files, which were once added (but not committed) and later removed using git reset --hard. See Recovering added file after doing git reset --hard HEAD^
When we push in our changes to some upstream repository, Are these blobs also pushed in?
Context: While doing any development, I occasionally do a git add on files changed, but don't commit them. This one time, I did a git add with some critical api credentials, and I was wondering if they could be recovered from the logs if I were to ever open-source the repo/gem.
No, blobs that were not committed (or pushed explicitely) are never transmitted over the wire.
If you added files and never committed, they should get removed with the next call to git gc
. If you however committed them, and then removed the commit again (e.g. through git rebase or git reset), they will not be collected because they are reachable through Git's reflog. But the reflog is a local mechanism and will not be published with git push
.