Search code examples
gitgithubmirror

Is it possible for a mirrored git repo miss commits?


On day 1, someone pushed a couple of commits into my GitHub repo. On day 2, I made a mirror clone of the repo using git clone --mirror. Then, I cloned it locally from the mirror and looked at the content. Neither of the commits are showing in the log or in the actual content of the files. It looks like as if the two commits where never there. Unfortunately, I rewrote the history for the repo after I mirrored it, so I cannot go back and cross-check. So, is it possible a mirror clone could be missing the commits or should I look for the problem elsewhere?


Solution

  • The local clone will checkout by default the master branch.

    If the commits were pushed on a different branch:

    • that branch is still present in the mirror clone
    • that branch is listed in the remote branches of the local clone (git branch -avv)

    But it wouldn't be checked out by default.

    Unfortunately, I rewrote the history for the repo after I mirrored it,

    You can still find the old history in git reflog, and make a temporary branch on the old history SHA1.

    See also "Duplicating a repository".