0

Need to push existing git repo to Gerrit however have issues doing this:

remote: ERROR: missing Change-Id in commit message footer

because repo did not contain .git/hooks/commit-msg. Now I have the script installed, however need to change hundreds of commit messages to add Change-Id everywhere. How to make it automatically in the best and easiest way? Possible solutions:

  1. I see some topics here suggest to use git rebase -i, however it is interactive and mostly manual process.
  2. Others to use sed command with git rebase as commit message editor. What is the exact rebase command will be in my case?
  3. Third proposes to use git filter-branch command, however it works only for commits on a current branch that have not yet been pushed to an upstream branch.

Any other solutions, fixes or suggestions for the above? Thanks!

Machavity
  • 30,841
  • 27
  • 92
  • 100
Aleksey Kontsevich
  • 4,671
  • 4
  • 46
  • 101
  • It seems nonsensical that Gerrit would require retroactively addding Change-Ids to an existing Git repository. Does this help? https://stackoverflow.com/questions/14789666/import-repository-from-git-to-gerrit – Schwern Sep 13 '18 at 21:40
  • @Schwern, our Gerrit set up to prohibit direct pushing bypassing review, or I do not have access rights to do this: command `git push gerrit HEAD:master` produces error: `! [remote rejected] HEAD -> master (prohibited by Gerrit)` – Aleksey Kontsevich Sep 13 '18 at 23:43
  • It seems you can bypass review by pushing to `HEAD:refs/heads/master`. See https://stackoverflow.com/a/16215375/14660 and https://gerrit-review.googlesource.com/Documentation/user-upload.html#bypass_review – Schwern Sep 14 '18 at 00:09
  • @Schwern, no I can't: still ` ! [remote rejected] HEAD -> master (prohibited by Gerrit)`. As mentioned in comment for https://stackoverflow.com/a/16215375/630169: this requires the 'Push' permission to be set on the 'Reference:refs/heads/*' section of the gerrit access panel. – Aleksey Kontsevich Sep 14 '18 at 00:36

1 Answers1

1

You need to do talk to the Gerrit administrators and ask for permission to push direct to branch bypassing review. Explain what you're trying to do telling that you just need this permission temporally (after the execution of the "git push gerrit HEAD:refs/heads/master" command the permission can be removed).

Other possibility: ask to the Gerrit administrators or someone who has permission to push to refs/heads/* (configuration managers use to have such permission) to execute the command for you.

Do NOT change retroactively the past commits, this isn't a good idea.