'Copy and overwrite Github Repo

I have a repo named github.com/someorganisation/somerepo.

A long time ago I copied it to github.com/someorganisation/somerepo-copy

Given that there has been a long time since this operation took place, I now want to force-copy/overwrite the entire github.com/someorganisation/somerepo to github.com/someorganisation/somerepo-copy

Do I have to empty github.com/someorganisation/somerepo-copy first?



Solution 1:[1]

Just delete somerepo-copy at GitHub. — Note that there is very little point having two identical but separate repos at GitHub. If the idea is to track somerepo in another repo, fork somerepo. That way, the fork can easily stay in sync with somerepo and won't go "stale" like this.

Solution 2:[2]

There's no need to empty it. You can just follow these steps:

warning: we are about to overwrite anything that exists on somerepo with the contents of somerepo-copy, so make sure that's what you really want because there is no going back.

(on somerepo-copy):

  1. git remote set-url origin [remote-url], replace [remote-url] with the repository's remote url, without the brackets.

  2. git push -f: assuming that both repos are almost commpletely different, we are using the flag -f to replace anything that exists on the remote server with whatever exists on your machine. If the repos aren't that different you could try using a regular git push.

after those 2 steps the folder somerepo-copy will be "linked" to the remote somerepo.

source: https://linuxize.com/post/how-to-change-git-remote-url/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 matt
Solution 2 toten