error while using " git push origin HEAD:refs/changes/xxxx "

1,174 views
Skip to first unread message

Sourav Srivastava

unread,
Mar 9, 2023, 2:34:53 AM3/9/23
to Repo and Gerrit Discussion
Hi Experts,

I have small query.  Trying to push chnages to existing open gerrit .
Using command:-

git push origin HEAD:refs/changes/xxxx

But I am getting error sharing it below.
I am using  gerrit admin user to push the changes.
Even I added explicit permission to do this but none of the options have worked out.
Looking for your expert comment to resolve this issue.
Permission added :  Create Referenc ; Add Patch Set ;  Forge Author Identity ;  Forge Committer Identity 
Reference: refs/heads/*

Error: 
 git push origin HEAD:refs/changes/1370/new-patch-set  --force
Counting objects: 3, done.
Delta compression using up to 30 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 346 bytes | 346.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1)
remote: error: branch refs/changes/1370/new-patch-set:
remote: You need 'Create' rights to create new references.   (I have already added this permission)
remote: User: adminuser
remote: Contact an administrator to fix the permissions
remote: Processing changes: refs: 1, done
To ssh://192.168.101.119:29418/QCM2290/VendorQCM2290/platform/pdk
 ! [remote rejected] HEAD -> refs/changes/1370/new-patch-set (prohibited by Gerrit: not permitted: create)
error: failed to push some refs to 'ssh://admi...@192.168.101.119:29418/QCM/Vendor/platform/pdk'


Any Quick expert advice will be very helpful.

Regards,
Sourav Srivastava

Sourav Srivastava

unread,
Mar 9, 2023, 4:03:10 AM3/9/23
to Repo and Gerrit Discussion
Hi ,

Tried this as well :- 
 git push origin -f HEAD:refs/changes/1370
Counting objects: 6, done.

Delta compression using up to 30 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), 591 bytes | 197.00 KiB/s, done.
Total 6 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2)

remote: Processing changes: refs: 1, done
To ssh://192.168.101.119:29418/QCM/Vendor/platform/pdk
 ! [remote rejected] HEAD -> refs/changes/1370 (Cannot create ref 'refs/changes/1370' because it already exists.)

error: failed to push some refs to 'ssh://admi...@192.168.101.119:29418/QCM/Vendor/platform/pdk'

Regards,
Sourav Srivastava

Wendy

unread,
Mar 9, 2023, 4:38:32 AM3/9/23
to Repo and Gerrit Discussion
Hi Sourav,

Is it possible you want to be pushing to refs/for/ instead i.e. refs/for/master or refs/for/<branch name>? You generally would not directly push anything to refs/changes/, which is a namespace Gerrit uses to track commits.

-Wendy

Sourav Srivastava

unread,
Mar 9, 2023, 5:13:36 AM3/9/23
to Repo and Gerrit Discussion
Hi Wendy, 

Yes, what you said is correct, but we can push to refs/changes/xxx as well. 
Sometime developers raise Gerrit which we can be changed or altered by another developer in same Gerrit number.
So that for some work we should not have multiple Gerrit numbers which will be hard to find.
So, some time it's easy to push on same Gerrit rather than new Gerrit.

Regards,
Sourav Srivastava

Sourav Srivastava

unread,
Mar 9, 2023, 5:51:13 AM3/9/23
to Repo and Gerrit Discussion
Hi,

Yes, you can push to Gerrit using the syntax "HEAD:refs/changes/1234".

This syntax is typically used when creating a new change or patch set in Gerrit.
The "HEAD" refers to the commit you want to submit for review, and "refs/changes/1234" is the destination ref where the change will be stored in Gerrit's database.
The number "1234" is the change number that Gerrit assigns to the change.

To use this syntax, you would run a git push command with the remote and branch name, followed by the destination ref. For example:

git push origin HEAD:refs/changes/1234
This would push the current commit to the Gerrit server, where it would be stored as a new change with the number 1234.
The change could then be reviewed and merged by other members of your team.

Regards,
Sourav Srivastava

Björn Pedersen

unread,
Mar 10, 2023, 8:35:33 AM3/10/23
to Repo and Gerrit Discussion
Sourav Srivastava schrieb am Donnerstag, 9. März 2023 um 08:34:53 UTC+1:
Hi Experts,

I have small query.  Trying to push chnages to existing open gerrit .
Using command:-

git push origin HEAD:refs/changes/xxxx

But I am getting error sharing it below.
I am using  gerrit admin user to push the changes.
Even I added explicit permission to do this but none of the options have worked out.
Looking for your expert comment to resolve this issue.
Permission added :  Create Referenc ; Add Patch Set ;  Forge Author Identity ;  Forge Committer Identity 
Reference: refs/heads/*



Has the server been upgraded recently? Since 3.1.0 this option has been finally removed.

I recommend to just adopt the normal flow of pushing to refs/for/...

Björn Pedersen

unread,
Mar 10, 2023, 8:43:37 AM3/10/23
to Repo and Gerrit Discussion
Sourav Srivastava schrieb am Donnerstag, 9. März 2023 um 11:13:36 UTC+1:
Hi Wendy, 

Yes, what you said is correct, but we can push to refs/changes/xxx as well. 
Sometime developers raise Gerrit which we can be changed or altered by another developer in same Gerrit number.
So that for some work we should not have multiple Gerrit numbers which will be hard to find.
So, some time it's easy to push on same Gerrit rather than new Gerrit.


It seems that you  are not configuring your local repos correctly. You need to enable the  gerrit commit msg hook (or you need to manually add 
Change-Id:  footer if you amend a commit). Then pushes to refs/for/.. will magically create a new patchset on a change ( don't call it "gerrit", that is the software).

for more infos
 

Regards,
Sourav Srivastava


Reply all
Reply to author
Forward
0 new messages