gitgerrit

git is updating two branches on gerrit server


when I do git push origin HEAD:refs/for/main the changes are being pushed to two branches. How can i just push to my branch? there is something messed up in my local settings.. I don't want to push any chagnes to 287913.

remote: 
remote:   https://git.team.com/r/c/product/+/287913 [wip] CI work
remote: 
remote: The following approvals got outdated and were removed:
remote: * Verified-1 by svc
remote: 
remote:   https://git.team.com/r/c/product/+/290536 [base image layers] port logic
remote: 
remote: The following approvals got outdated and were removed:
remote: * Verified-1 by svc
remote: 
remote: 

Solution

  • Creating/updating 2 pending changes in 1 push means you have 2 sequential new commits. One corresponds to 287913, and the other to 290536. If they are not dependent on each other, you can split them up onto 2 local develop branches.

    Check their commits on Gerrit Change page. Suppose 287913 is abc123 and 290536 is def789.

    # Create 2 local dev branches for each change
    git fetch origin main
    git branch dev_287913 FETCH_HEAD
    git branch dev_290536 FETCH_HEAD
    
    # Apply the 2 commits onto the dev branches
    git switch dev_287913
    git cherry-pick abc123
    git switch dev_290536
    git cherry-pick def789
    

    If there are any conflicts, resolve them. The 2 changes are still open, so you can amend them and push to update the pending changes if necessary. During the process, please keep the Change-Id in the commit message unchanged so that the amended commits can still be attached to the same pending change.