Split project without change duplication

74 views
Skip to first unread message

Daniil Gan’kov

unread,
Jun 17, 2025, 11:29:43 AM6/17/25
to Repo and Gerrit Discussion
Hello.

I want to split one super-project with multiple branches into multiple projects with one main branch:

super-project (branch-a, branch-b) -> project-a (main) + project-b (main), where branch-a at super-project == main at project-a and branch-b at super-project == main at project-b

I have a single Gerrit instance with NoteDb backend. I want to save the whole change history with the same change numbers but altered branches and projects. Changes must not be duplicated.

The solution I see is:

1. Stop Gerrit,
2. Initialize a new project-a.git bare repo in Gerrit's git directory,
3. Push refs/meta/config at super-project to refs/meta/config at project-a as is,
4. Push refs/heads/branch-a at super-project to refs/heads/branch-a at project-a as is,
5. Find refs/changes/<change-number>/meta which nearest parents have "Branch: branch-a" trailer and push refs/changes/<change-number>/* from super-project to project-a as is,
6. Rename branch-a to main,
7. Commit "Branch: main" trailer to the pushed refs/changes/*/meta references,
8. Do the same for project-b,
9. Delete super-project,
10. Rebuild cache and index.

Am I right that this method will do what I want?

Cheers,
Daniil Gankov

Sven Selberg

unread,
Jun 18, 2025, 1:40:16 AM6/18/25
to Repo and Gerrit Discussion
On Tuesday, June 17, 2025 at 5:29:43 PM UTC+2 Daniil Gan’kov wrote:
Hello.

I want to split one super-project with multiple branches into multiple projects with one main branch:

super-project (branch-a, branch-b) -> project-a (main) + project-b (main), where branch-a at super-project == main at project-a and branch-b at super-project == main at project-b

I have a single Gerrit instance with NoteDb backend. I want to save the whole change history with the same change numbers but altered branches and projects. Changes must not be duplicated.

The solution I see is:

1. Stop Gerrit,
2. Initialize a new project-a.git bare repo in Gerrit's git directory,
3. Push refs/meta/config at super-project to refs/meta/config at project-a as is,
4. Push refs/heads/branch-a at super-project to refs/heads/branch-a at project-a as is,

If the branch will be called main eventually I don't think you have anything to gain by pushing to branch-a and renaming it, I'd push the branch directly to project-a:refs/heads/main.

Nasser Grainawi

unread,
Jun 19, 2025, 10:30:36 AM6/19/25
to Sven Selberg, Repo and Gerrit Discussion
It looks like it could work. Please do share back here with your results as I haven't seen someone attempt this scenario previously :)
 

Cheers,
Daniil Gankov

--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/repo-discuss/6f1558df-76ab-47ca-a0e2-7a754303ba0dn%40googlegroups.com.

Daniil Gan’kov

unread,
Jun 20, 2025, 9:19:31 AM6/20/25
to Repo and Gerrit Discussion
It seems to work.

But there are some remarks on the implementation:

1. It is not easy to just share refs/meta/config between projects especially when branches are renamed. I found it is simpler to configure the moved project from scratch.
2. "Branch: <new>" trailer is not enough for the commit over refs/changes/*/meta. It also must contain "Patch-set: <latest>" for Gerrit to reindex changes without an exception.
3. refs/notes/review becomes inconsistent after these actions. As I found, it is enough to just run "reviewnotes export" over SSH to update these refs over all projects.

And thanks, Sven, for your advice.
Reply all
Reply to author
Forward
0 new messages