Swap fork and parent repositories but keep everything else as-is

I have a situation where a repo exists under one organization. I would like to “transfer” it to another organization, fork it back to original and keep all the PR info and issues, etc, in the original. Basically, I want to keep discussion as it was but convert the current parent to a fork.

An alternative approach may be like:

  1. org/repoA
  2. create fork newowner/repoA from org/repoA
  3. swap fork_id in the DB so that newowner/repoA is the parent of org/repoA

Is this viable alternative or is something liable to break here?

The parent repositories will add all the first level forks as it’s remote . Maybe you can copy the whole disk git repository to the new parent after all above steps so that the remotes will be kept in the parent repository.

OK, that’s good to know that this will work and there aren’t some terribly dragon hiding somewhere. Actually, I would like to keep the forks of the original repo as-is, just slip new parent in there. Then I guess adding a remote to the fork would do the trick.

So, a quick update. We tested on 1.24.2 and it seems to work well.

  1. create new fork /fork/pkg from /orig/pkg
  2. swap fork_id
  3. swap is_fork
  4. adjust num_forks +1 and -1 accordingly

Nothing else changes. The changes were visible online, without needing to restart Gitea. Sync with Fork was visible in /orig/pkg when adding new commits to the new parent /fork/pkg – as expected.

We were also testing remotes in the gitea repositories, but these don’t seem to affect much. Both PR creation and the sync fork functionality is not affected by these remote setting in the actual git repository.

Is there actual usage for the remote repo setting in the actual git repository inside Gitea?

Would it make sense to add this feature as a API call? For example, as part of the createFork API with an option like reparent=true?