I'm wondering if a remote git
repo does (or should do) automatic delete of unreferenced file objects (and also trees) once it received a push
from local, after rebasing local and skipping some commits that introduced those files and also these commits deleted those files. Since these skipped commits are no longer in the history chain of commits it's logical that remote delete these objects as they are now not part of any commit in the history. This graph may explain it:
This is the history before rebase --onto
* b5b7c142 after-deleting offending-file * db759b06 deleted offending-file * 59a9440a added offending-file * 933729b1 before-adding-offending-file
which was pushed to the remote before I regret it. But here comes the attempt to fix it...
rebase --onto 933729b1 db759b06
which effectively reconstructs commit b5b7c142 after-deleting offending-file
to have a different parent: 933729b1 before-adding-offending-file
and leaving the middle two commits simply ignored.
This is how it looks after the rebase above: (please note that first commit SHA1 changed because we changed parent)
* 17c95f49 after-deleting offending-file | * db759b06 deleted offending-file | * 59a9440a added offending-file | / * 933729b1 before-adding-offending-file
and it's looking ok for a history on local and that file object still exists in .git/objects, it's a part of some commits that are here still. Now what happens if I pushed now to the remote? Will it delete that file object in .git/objects
on github as it's now not part of any commit/tree? And if not, how can I do that?