Using just `git push`

2,390 views
Skip to first unread message

Steffen Gebert

unread,
Jun 10, 2011, 3:58:53 PM6/10/11
to Repo and Gerrit Discussion
Hi,

Alex Blewitt explained a Git+Gerrit+Jenkins setup here:
http://www.infoq.com/articles/Gerrit-jenkins-hudson

He sets
$ git config remote.origin.push refs/heads/*:refs/for/*
and can then use
$ git push
instead of the lengthy
$ git push origin HEAD:refs/for/<branch>
(we do not use repo).

I already tried this, but then Git tries to push everything from all branches (and Gerrit rejects it with "duplicate request" IIRC).

Does this only work, when you're just dealing with one single (master) branch? We have several released branches, I wasn't able to push anything successful, when I tried this a week ago.

I know that I must work on a branch with the same name as the target branch to which I want to push.

Thanks for your answer

Kind regards
--
Steffen Gebert
TYPO3 v4 Core Team Member

TYPO3 .... inspiring people to share!
Get involved: http://typo3.org

Matthias Sohn

unread,
Jun 10, 2011, 4:08:43 PM6/10/11
to Steffen Gebert, Repo and Gerrit Discussion
2011/6/10 Steffen Gebert <ste...@steffen-gebert.de>

Hi,

Alex Blewitt explained a Git+Gerrit+Jenkins setup here:
http://www.infoq.com/articles/Gerrit-jenkins-hudson

He sets
$ git config remote.origin.push refs/heads/*:refs/for/*
and can then use
$ git push
instead of the lengthy
$ git push origin HEAD:refs/for/<branch>
(we do not use repo).

I already tried this, but then Git tries to push everything from all branches (and Gerrit rejects it with "duplicate request" IIRC).

Does this only work, when you're just dealing with one single (master) branch? We have several released branches, I wasn't able to push anything successful, when I tried this a week ago.

I know that I must work on a branch with the same name as the target branch to which I want to push.

I use several remotes if I work against multiple upstream branches in Gerrit
e.g.

[remote "review"]
fetch = +refs/heads/*:refs/remotes/origin/*
fetch = +refs/notes/review:refs/notes/review
push = HEAD:refs/for/master
[remote "review-1.0"]
push = HEAD:refs/for/stable-1.0

for pushing to code review for refs/for/master I say 
$ git push review
 
and for stable-1.0 code review I say
$ git push review-1.0

--
Matthias

Shawn Pearce

unread,
Jun 10, 2011, 9:10:25 PM6/10/11
to Steffen Gebert, Repo and Gerrit Discussion, Matthias Sohn
On Fri, Jun 10, 2011 at 13:08, Matthias Sohn
<matthi...@googlemail.com> wrote:
> 2011/6/10 Steffen Gebert <ste...@steffen-gebert.de>

>>
>> Alex Blewitt explained a Git+Gerrit+Jenkins setup here:
>> http://www.infoq.com/articles/Gerrit-jenkins-hudson
>>
>> He sets
>> $ git config remote.origin.push refs/heads/*:refs/for/*

This only works if you have exactly one local branch. If you have more
than one local branch, yes, Gerrit errors out.

I suggest Matthias' approach (below).

Steffen Gebert

unread,
Jun 11, 2011, 7:57:01 AM6/11/11
to Repo and Gerrit Discussion
>>> He sets
>>> $ git config remote.origin.push refs/heads/*:refs/for/*
>
> This only works if you have exactly one local branch. If you have more
> than one local branch, yes, Gerrit errors out.
>
> I suggest Matthias' approach (below).

Thanks, Matthias and Shawn!

Reply all
Reply to author
Forward
0 new messages