Search code examples
iosreactjsgitreact-nativegerrit

Is it possible to push changes into a branch which is already merged in Gerrit


I have a branch named bugs_feature which i have already merged into develop branch. Next time when i work on the same branch which has fix for some other bug, Can i push that fix for code review to same branch bugs_feature which is already in merged state.

I have tried with below commands, but it din't work

      xxxx@xxxx-MacBook-Pro SampleApp % git commit -m "Fixed issue HRODS-945"
   [bugfix_dashboard 226f6b6] Fixed issue HRODS-945
    5 files changed, 78 insertions(+), 45 deletions(-)
   xxxx@xxxx-MacBook-Pro SampleApp % git push 
   "https://xxxx@reviewba.xxxxx.com:8459/a/Sample/Sample-mobile-app" 
   HEAD:refs/for/bugfix_dashboard

   Counting objects: 34, done.
   Delta compression using up to 8 threads.
   Compressing objects: 100% (22/22), done.
   Writing objects: 100% (34/34), 4.43 KiB | 1.48 MiB/s, done.
   Total 34 (delta 19), reused 0 (delta 0)
   remote: Resolving deltas: 100% (19/19)
   remote: Processing changes: refs: 1, done    
   To https://reviewba.xxxx.com:8459/a/Sample/sample-mobile-app
   ! [remote rejected] HEAD -> refs/for/bugfix_dashboard (change 
   https://reviewba.xxxxx.com:8459/c/Sample/sample-mobile-app/+/185 closed)
   error: failed to push some refs to 
  'https://xxxxxx@reviewba.xxxxx.com:8459/a/Sample/sample-mobile-app'

Even tried with git commit --amend and modified the changed Id, so gerrit might consider it as a new push for code review.

Is it because the branch is already in merged i'm not able to push or Gerrit doesn't support pushing code to a already merged branch.

Thanks.


Solution

  • This worked for me after following the hint from the git command prompt message.

      remote: ERROR: commit ac81273: invalid Change-Id line format in message footer
      remote: 
      remote: Hint: run
      remote:   git commit --amend
      remote: and move 'Change-Id: Ixxx..' to the bottom on a separate line
      remote: 
    

    Step 1 : After using the git commit -amend

    when you enter into the edit format of the earlier commit message screen.

    Step 2 :Go to line of the Change ID and move it to couples of lines down and on Top

    Step 3 :Type Change Id: "your commit Id goes here"(should be like the below format).

    • It starts with an uppercase I;
    • It contains 32 hexadecimal characters;

    One sample format could be :

    I201611160832aa0000000000786176696572
    

    It starts with the date and time (YYYYMMDDHHMM), followed by a separator, and then the name of the committer in hexa format (here i used ascii, but one could use another format), padded with 00.