Push existing repositories to Gerrit.

5,006 views
Skip to first unread message

hakie

unread,
Aug 24, 2010, 5:44:53 AM8/24/10
to Repo and Gerrit Discussion
Hi all,

I want to introduce Gerrit system into our workflow.
I have installed Gerrit and the basic operation is workable.
Now i am going to push all repositories from the orginal server to
Gerrit server.
I've doing the searching for a while, but still have no idea how to do
push all repositories to Gerrit server in an easy way.
The only one way i know is to create each project manually.
ex: ssh -p 29418 hostname gerrit create-project --name projectname

And push all commits to Gerrit
ex: git push ssh://sshusername@hostname:29418/projectname HEAD:refs/
for/branchname

But this way is very stupid.
So anyone can tell me how you moved all repositories from outside to
Gerrit server.

Thank you.

Justin
Message has been deleted

Magnus Bäck

unread,
Aug 24, 2010, 6:12:59 AM8/24/10
to Repo and Gerrit Discussion
On Tuesday, August 24, 2010 at 11:44 CEST,
hakie <haki...@gmail.com> wrote:

Pushing to refs/for/branchname will create changes for each commit,
and this would of course be stupid, but if you instead push to
refs/heads/branchname you'll bypass the code review and push the
commits straight into the branch.

Now, a git is just files in a file system so you could use
rsync or similar, but I'd just push everything.

I've experienced out of memory problems when pushing a large repository
(like the Linux kernel) to the server, but that was over a year ago on
an underpowered virtual machine with an old Gerrit release. A workaround
then was to push a little bit a time instead of everything in one go.

--
Magnus B�ck Opinions are my own and do not necessarily
SW Configuration Manager represent the ones of my employer, etc.
Sony Ericsson

hakie

unread,
Aug 24, 2010, 9:29:21 AM8/24/10
to Repo and Gerrit Discussion
Thank for your reply.

So you mean if i have a hundred of git projects, I would create them
first by a hand-written script. And push them each by each?

Thank you~

Justin

On 8月24日, 下午6時12分, Magnus Bäck <magnus.b...@sonyericsson.com> wrote:
> On Tuesday, August 24, 2010 at 11:44 CEST,

Magnus Bäck

unread,
Aug 24, 2010, 9:50:18 AM8/24/10
to repo-d...@googlegroups.com
On Tuesday, August 24, 2010 at 15:29 CEST,
hakie <haki...@gmail.com> wrote:

> So you mean if i have a hundred of git projects, I would create them
> first by a hand-written script. And push them each by each?

Something like that. Of course, given a list of gits the creation and
push operations would be accomplished with a simple for loop in the
shell. If you have the gits listed in a Repo manifest you can even have
Repo do the looping for you -- have a look at the "repo forall" command.

Nasser Grainawi

unread,
Aug 24, 2010, 10:08:25 AM8/24/10
to hakie, Repo and Gerrit Discussion
On 08/24/2010 03:56 AM, hakie wrote:
> Hi all,

>
> I want to introduce Gerrit system into our workflow.
> I have installed Gerrit and the basic operation is workable.
> Now i am going to push all repositories from the orginal server to
> Gerrit server.
> I've doing the searching for a while, but still have no idea how to do
> push all repositories to Gerrit server in an easy way.
> The only one way i know is to create each project manually.
> ex: ssh -p 29418 hostname gerrit create-project --name projectname
>
> And push all commits to Gerrit
> ex: git push ssh://sshusername@hostname:29418/projectname HEAD:refs/
> for/branchname
>
> But this way is very stupid.
> So anyone can tell me how you moved all repositories from outside to
> Gerrit server.
>
> Thank you.
>
> Justin
>

You could rsync them, then re-run the 'init' command and tell it where
you rsync'ed the gits to.

Nasser

--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

Shawn Pearce

unread,
Aug 24, 2010, 1:19:49 PM8/24/10
to Repo and Gerrit Discussion
On Tue, Aug 24, 2010 at 03:12, Magnus Bäck <magnu...@sonyericsson.com> wrote:
> On Tuesday, August 24, 2010 at 11:44 CEST,
>     hakie <haki...@gmail.com> wrote:
>
>> I want to introduce Gerrit system into our workflow.
>> I have installed Gerrit and the basic operation is workable.
>> Now i am going to push all repositories from the orginal server to
>> Gerrit server.
>
> Pushing to refs/for/branchname will create changes for each commit,
> and this would of course be stupid, but if you instead push to
> refs/heads/branchname you'll bypass the code review and push the
> commits straight into the branch.

If you do this, you need to ensure you have granted yourself the
following permissions:

Push Branch +2 (or +3)
Forge Identity +2 (or +3)

I would just add these to -- All Projects -- for group Administrators
and reference refs/*. That way you can push to all of your projects
to setup the import, and then remove these two lines once done.

hakie

unread,
Aug 25, 2010, 4:57:49 AM8/25/10
to Repo and Gerrit Discussion
Thanks for all your reply.

I have done this job by using "repo forall" to do "create project" and
"push" from my existing project to Gerrit server.
The commnad is like below:

1. repo forall -c 'ssh -p 29418 USER...@codereview.example.com gerrit
create-project --name $REPO_PROJECT'

2. repo forall -c 'git push ssh://USER...@codereview.example.com:29418/${REPO_PROJECT}
HEAD:refs/heads/master'

Hopefully this will be helpful to others as well.

Gracias~

Hakie

On 8月25日, 上午1時19分, Shawn Pearce <s...@google.com> wrote:
> On Tue, Aug 24, 2010 at 03:12, Magnus Bäck <magnus.b...@sonyericsson.com> wrote:
> > On Tuesday, August 24, 2010 at 11:44 CEST,
Reply all
Reply to author
Forward
0 new messages