如何通过命令从 git 提交中删除 Change-Id
How to remove Change-Id from git commit by command
当我从 Gerrit 中挑选一个补丁并将其再次推送到同一服务器上的不同分支时,服务器回复错误消息:
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'
使用 git commit --amend
删除 Change-Id
行可以解决这个问题。
我想写一个脚本来自动完成。有没有command/parameter达到同样的结果?
您可以使用 --no-commit
选项;类似的东西(你需要调整它)
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"
当我从 Gerrit 中挑选一个补丁并将其再次推送到同一服务器上的不同分支时,服务器回复错误消息:
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'
使用 git commit --amend
删除 Change-Id
行可以解决这个问题。
我想写一个脚本来自动完成。有没有command/parameter达到同样的结果?
您可以使用 --no-commit
选项;类似的东西(你需要调整它)
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"