0

I am trying to migrate my OLD GitLab repo code.old-gitlab.cloud:legacy/OCG/my-big-repo.git to new GitHub repo code.new-github.cloud:legacy/OCG/my-big-repo.git ( Both servers are hosted on our company servers )

My new repo is completely empty ( no branches created at all ) : code.new-github.cloud:legacy/OCG/my-big-repo.git

But when I try to migrate old repo to new repo with 3 steps as below, I am running into issue. I am following 3 step solution suggested from this thread : Push local Git repo to new remote including all branches and tags

C:\migrate2>git clone --bare git@code.old-gitlab.cloud:legacy/OCG/my-big-repo.git
C:\migrate2>cd my-big-repo.git
C:\migrate2\my-big-repo.git>git push --mirror git@code.new-github.cloud:legacy/OCG/my-big-repo.git

Enumerating objects: 321124, done.
Counting objects: 100% (321124/321124), done.
Delta compression using up to 4 threads
Compressing objects: 100% (50306/50306), done.
Writing objects: 100% (321124/321124), 509.54 MiB | 1.84 MiB/s, done.
Total 321124 (delta 250948), reused 321124 (delta 250948)
remote: Resolving deltas: 100% (250948/250948), done.
remote: Checking connectivity: 321124, done.
remote: fatal error in commit_refs
To code.new-github.cloud:legacy/OCG/my-big-repo.git
! [remote rejected]       6722-GenerateEFTpaymentsforaffiliationsthatareconfiguredforEFTpayments -> 6722-GenerateEFTpaymentsforaffiliationsthatareconfiguredforEFTpayments (failure)
! [remote rejected]       AA-8149-New-Screen-IQ1350-IQ1360 -> AA-8149-New-Screen-IQ1350-IQ1360 (failure)

....................continues with similar error messages for all other branches
  • 3
    The message `fatal error in commit_refs` is coming from something happening on the `code.new-github.cloud` server. It does not appear to be Git itself, which has no occurrences of `commit_refs` in it anywhere, so what it *is* coming from is a mystery. Contact whoever does your GitHub Cloud support. – torek Nov 13 '21 at 03:12
  • Do any of your refs get pushed? Do you have protected branch settings or restrictions on who can push or requirements for pull requests to push to the repository? Maybe see [How do I fix "remote: fatal error in commit_refs" errors trying to push with Git?](https://stackoverflow.com/questions/37341960/how-do-i-fix-remote-fatal-error-in-commit-refs-errors-trying-to-push-with-git) – sytech Nov 13 '21 at 19:37

1 Answers1

0
Assuming you have installed gh-code ( the command line tool from GitHub )

• Step-1: Create clone repository for my-big-repo (of GitLab) as below for mirroring: git clone --mirror git@code.old-gitlab.cloud:legacy/OCG/my-big-repo.git

• Step-2: Extract Git tag names to file (which we are going to push in the next steps)

• Step-3: Change directory to my-big-repo.git directory

• Step-4: Create my-big-repo project in GitHub.

• Step-5: Add this new Github repository as remote to downloaded clone repository as below: git remote add gh-code git@code.new-github.cloud:legacy/OCG/my-big-repo.git

• Step-6: Now push all branches git push gh-code --all

• Step-7: Push tags to Github repository (if existing Gitlab repository has clean tags). Otherwise follow below Step 8.

• Step-8: Now push each tag into new Github repository from Step 2. a) Our code base has more than 8000 tags hence we have to loop through extracted tags file in parallel mode as below:

#!/bin/bash

input="javatags.txt"

count=1

while IFS= read -r line

do

git push -f gh-code $line 2 &

count=expr $count + 1

if (( $count % 50 == 0 )); then wait; fi # Limit to 50 concurrent subshells.

done < "$input"

wait

echo "All done"

  • This is dramatically overcomplicated. Make your new hosted repo wherever, `git clone --mirror old/hosted/url; cd into.it; git push --mirror new/hosted/url`. – jthill Dec 03 '21 at 17:35
  • It doesn't work for some reason and that is why these steps were created. This is a work around when those simple mirror push doesn't work. It can happen when your repo may have too many tags and sometime tags, branches may have special characters like < , that mirror push may fail. See my original post. – Bakul Brahmbhatt Dec 03 '21 at 22:43
  • Except your post says you did `git clone --bare`, not `git clone --mirror`, and the docs for the "remote rejected" say it's usually a hook or some specific condition you're not going to have on a new repo. When I do a mirror push with one of the branch names you listed, it works. So why your hosting provider rejected it, you'll have to find out from them. – jthill Dec 04 '21 at 00:11