3

So while trying to migrate a repository from bitbucket to github, I followed some steps to do the following:

1- git clone --mirror <bitbucket_repo>

2- cd in the repo folder

3- git push --mirror <github_repo>

And then to make sure all my commits are copied, I ran the following command in the cloned bitbucket_repo folder:

git rev-list --count --all

That gave me 25551 commits

And then I cloned the newly created github repo (with --mirror) and then ran the same command and I got 25557 commits

Now, I understand if the number of commits in the newly created repo is less. But I am getting more. I thought that git clone --mirror copies ALL the refs.

So I cloned the bitbucket repo without the --mirror option and checked the number of commits and it was 25557 commits.

I cloned the newly created github repo without the --mirror option and checked the number of commits and it was 25557 commits.

What am I missing here?

P.S: It is worth noting that when I run git rev-list --all --count --no-merges, all the commit numbers match!

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
Mohamed
  • 360
  • 1
  • 10
  • And what if you say `--merges` instead? – matt May 30 '21 at 06:43
  • 2
    [`--mirror` copies all refs](http://git-scm.com/docs/git-clone#Documentation/git-clone.txt---mirror) – dan1st May 30 '21 at 07:04
  • @matt `--merges` gives different results. @dan1st yes, I know. I am cloning all the refs and then pushing all the refs and yet the number of commits do not match. That's what I am trying to understand! – Mohamed May 30 '21 at 07:39
  • 25551 (count from cloning bitbucket repo) < 25557 (count from cloning github repo). Something *added* 6 commits between the two steps. What added six commits? I have no idea. – torek May 30 '21 at 08:47
  • @torek there are literally no steps between the two. `git clone --mirror `, `cd .git`, `git push --mirror ` – Mohamed May 30 '21 at 08:54
  • Your question says you ran `git clone --mirror` (from bitbucket), then `git push --mirror` (to github), then `git clone --mirror` (from github). Again, clearly something added 6 commits. What added those commits? It might be interesting to enumerate the commits in the two local mirror clones and see what the six extra ones are. (Assuming you have standard Unix tools, use `git rev-list` on each and `comm` on the outputs.) – torek May 30 '21 at 09:40
  • @torek I do see the extra commits. But that is not my question. According to every article that I read to do a repo migration, they suggest the clone with mirror option to copy all the refs. And I do not have a problem with that. My question is why doesn't the number of commits match if I am cloning with mirror from bitbucket and pushing with mirror to github and then cloning again from github (just to confirm). Clearly those extra commits came from the bitbucket repo so why does it not read them in the first place when I clone from bitbucket! – Mohamed May 31 '21 at 06:30
  • I don't know. If I knew, I would have written an answer, instead of a comment. Comparing the two repositories to see what introduced these six commits *might* **lead to** an answer. Or it might not. It isn't an answer, it's just a comment. – torek May 31 '21 at 09:29
  • @Mohamed : technically, some time elapsed between `git push to github` and `git clone from github`. Is it possible that *something* or *someone* added 6 extra commits between these two steps ? if you copy/paste your initial bitbucket local repo, and run `git fetch from github`, do you see 6 extra commits appear ? – LeGEC Jun 14 '21 at 08:21
  • (copy/pasting would be to keep the original state of your starting repo) – LeGEC Jun 14 '21 at 08:22

0 Answers0