简体   繁体   中英

How to remove Change-Id from git commit by command

When I cherry-pick a patch from Gerrit and push it again to different branch on same server, the server reply error message:

Total 0 (delta 0), reused 0 (delta 0)
remote: Processing changes: refs: 1, done
To ssh://xxxxxx.git
 ! [remote rejected] HEAD -> refs/for/xxxx (no new changes)
error: failed to push some refs to 'ssh://xxxxxx.git'

Using git commit --amend to remove Change-Id line can fix this problem.

I want to write a script to do it automatically. Is there any command/parameter to achieve same result?

You could use the --no-commit option; something like (you'll need to tweak this)

git cherry-pick --no-commit <sha-1>
COMMIT_MSG=$(git log -n 1 --pretty=format:%s%b <sha-1>)
# some bash operation to remove the Change-id from COMMIT_MSG variable
git commit -m "$COMMIT_MSG"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM