Change Default HEAD : master in gerrit to myown new Branch

803 views
Skip to first unread message

Sourav Srivastava

unread,
May 24, 2021, 10:17:35 AM5/24/21
to Repo and Gerrit Discussion

Hi,

Need Help!!!

I have one Gerrit server and in a AOSP project I have added one new Directory.
did Empty commit directly bypassing code review with remote as user root directly.

Issue:-

I am not able to change HEAD : master to another mybranch name
when I push it create another branch rather than updating HEAD from master to mybranch.

git push origin HEAD:refs/heads/mybranch

earlier I have used this and it used to change default head but now its not working.
Please help.


Sven Selberg

unread,
May 24, 2021, 10:27:30 AM5/24/21
to Repo and Gerrit Discussion
On Monday, May 24, 2021 at 4:17:35 PM UTC+2 sourav.s...@gmail.com wrote:

Hi,

Need Help!!!

I have one Gerrit server and in a AOSP project I have added one new Directory.
did Empty commit directly bypassing code review with remote as user root directly.

Issue:-

I am not able to change HEAD : master to another mybranch name
when I push it create another branch rather than updating HEAD from master to mybranch.

git push origin HEAD:refs/heads/mybranch

This just pushes whatever your local HEAD points to to "refs/heads/mybranch" on origin.
You can update default HEAD on origin (if you have access) in the "Branches" section of the Repository settings in the UI.
Or directly through the Set Head REST endpoint:
https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#set-head
 

Sourav Srivastava

unread,
May 24, 2021, 12:13:08 PM5/24/21
to Repo and Gerrit Discussion
Thanks Sven Selberg  for you response to my Query.

I have gone through this url before updating my query here. But it didn't help.
UI I tried but somehow it changed but when I pushed changes from client it didn't went through returned some error.
I really don't know how to use the other option  which is Set Head TEST endpoint.

In Github its too easy to do it :)  

Sven Selberg

unread,
May 25, 2021, 2:54:44 AM5/25/21
to Repo and Gerrit Discussion
On Monday, May 24, 2021 at 6:13:08 PM UTC+2 sourav.s...@gmail.com wrote:
Thanks Sven Selberg  for you response to my Query.

I have gone through this url before updating my query here. But it didn't help. 
UI I tried but somehow it changed but when I pushed changes from client it didn't went through returned some error.
I'm sorry I don't understand what you mean.
Did you manage to change HEAD? If so that's what you were trying to accomplish.
What do you mean by "I pushed changes from client it didn't went through returned som error"?
Changing HEAD shouldn't change the behavior of pushing to branches or for review.
What did you push?
What did the error say?
How did you draw the conclusion that the error was caused by the changing of HEAD?
 

Sourav Srivastava

unread,
May 25, 2021, 6:16:33 AM5/25/21
to Repo and Gerrit Discussion
Hi Sven Selberg,

1. Did you manage to change HEAD?
  No The default head still points to master in gerrit .
 

2. What did you push?
I created a directory on my local machine , created a file did a commit and pushed it to gerrit server.
git push origin HEAD:refs/heads/mybranch
Note :  here I am not using remote with gerrit user , I am directly pushing to gerrit with user ubuntu . I am bypassing gerrit code review system.
            
3. What did the error say?
Error When I tried to pushed it through Gerrit User : -

git push origin HEAD:refs/for/mybranch
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 42 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 1.97 KiB | 1.97 MiB/s, done.
Total 4 (delta 0), reused 0 (delta 0)
remote: Processing changes: new: 1, refs: 1, done
remote:
remote: New Changes:
remote: http://10.0.0.100:8080/#/c/AndR/tools/mmxscript/+/242 N23 : Build Display
remote:
To ssh://10.0.0.100:29418/AndR/tools/mmxscript
! [remote rejected] HEAD -> refs/for/mybranch (internal server error: Error inserting change/patchset)
error: failed to push some refs to 'ssh://us...@10.0.0.100:29418/AndR/tools/mmxscript'

Björn Pedersen

unread,
May 25, 2021, 8:10:44 AM5/25/21
to Repo and Gerrit Discussion
I suspect  you managed to mess up access rights as you pushed to the gerrit-managed repo without going through gerrit ( the default ubuntu install runs as user  gerrit, not ubuntu) . 

Don't do that unless you really   understand how gerrit works. Instead you need 'Create branch'  and push permission on refs/heads/* for your user ( see gerrit docs [1] for details).
So always push to the gerrit ssh port! To fix this check that the ownership on the server is set to the user running gerrit.

Sourav Srivastava

unread,
May 26, 2021, 1:20:57 AM5/26/21
to Repo and Gerrit Discussion
Thanks for your Reply !!
I will fix this taking your suggested method .
Reply all
Reply to author
Forward
0 new messages