0

I had multiple repositories on GitHub, now I shifted them to GitLab.

My developer commits changes on GitHub files.

Now, is there any solution that the changes committed on GitHub will also change files on GitLab?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250

1 Answers1

0

If, when "shifted", those repositories were pushed from a local GitHub copy to GitLab, they are sharing a common history.

That means, from your local GitLab clone, you can:

  • add the old GitHub URL as a remote
  • fetch from GitHub
  • merge that fetched branch to your GitLab branch
  • push to your normal origin remote (GitLab URL)
cd /path/to/GitLab/local/clone
git remote add github https://github.com/old/project
git fetch github
git merge github/main
git push

The other approach, as commented, would be for your developer to push both to GitHub and GitLab, assuming said developer is the only one working on the current branch in both repository (or it starts to involve complex synchronization steps before any push to both repositories)

# For developer working on GitHub
cd /path/to/GitHub/local/clone
git remote set-url origin --push --add https://github.com/old/project
git remote set-url origin --push --add https://gitlab.com/new/project
# work: add and commit
git push
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250