Sync Same Git Repo Between Different Version Control Systems

Aug 27, 2023  │  m. Aug 27, 2023 by Omar ElKhatib  │  #git  
Disclaimer: Views expressed in this software engineering blog are personal and do not represent my employer. Readers are encouraged to verify information independently.

Introduction

Hello, years back I decided to migrate to codeberg because of disagreement with github policies

Now I decided to move back to github, so the problem I faced is that my repos are outdated on github and I need to get the updates from codeberg.

Solution 1

The first solution was to delete repo from github then use import feature in github to import repo from codeberg. That works but we loose a lot of stuff when doing so, like stars.

1 star

Kanna Kamui

This works but I can't risk loosing my lovely 1 star.

Solution 2

The better solution is to clone the old repo in github

git clone git@github.com:khatibomar/tohru.git
cd tohru

if I run the git log command I get this output the HEAD is at commit 6c7bb

commit 6c7bb681db24c79e48f8010e100d5bd3f37516d8 (HEAD -> main, origin/main, origin/HEAD)
Author: OmarElKhatibCS <omarelkhatib@mail.com>
Date:   Thu Dec 16 15:14:33 2021 +0200

    add new option to return first live streaming link

    that will have better performance for apps that don't need more than one
    link because it doesnt wait for other slower ones

to get the new changes from another repo, I used git pull

git pull https://codeberg.org/omarkhatib/tohru.git

output

remote: Enumerating objects: 23, done.
remote: Counting objects: 100% (23/23), done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 44 (delta 11), reused 5 (delta 5), pack-reused 21
Unpacking objects: 100% (44/44), 351.16 KiB | 56.00 KiB/s, done.
From https://codeberg.org/omarkhatib/tohru
 * branch            HEAD       -> FETCH_HEAD
Updating 6c7bb68..73d6a12
Fast-forward
 .github/assets/logo.gif | Bin 498471 -> 347621 bytes
 README.md               |   1 +
 anime.go                | 137 ++++++++++++++++++++++++++++++++++----
 client.go               |   1 +
 config.go               |   9 +--
 episode.go              | 173 ++++++++++++++++++++++++++++++++++++++++++------
 go.mod                  |   9 ++-
 go.sum                  |  15 ++++-
 listype.go              |   2 +-
 order.go                |   2 +-
 payload.go              |  48 ++++++++++++--
 season.go               |   2 +-
 12 files changed, 349 insertions(+), 50 deletions(-)

if I run git log again, the head now is at commit 73d6a

commit 73d6a120a6e3faac79171cc5fd66b256111498d0 (HEAD -> main)
Author: omarkhatib <elkhatibomar@outlook.com>
Date:   Sat Nov 26 09:35:43 2022 +0200

   Fix bug in payload

after that I can push the changes to github repo

git push -u origin main