我的團隊正在與 Gerrit 合作。
現在,我和兩個同事正在做一個專案。
兩者都git push對Gerrit,意味著Gerrit上已經發生了兩次獨立的變化。
現在,我需要獲取他們的更改,將它們合并到我的本地專案中,并將新的更改推送到 Gerrit。
假設現有的兩個更改是A和B。
在我的本地機器上,我執行以下操作:
git checkout master && git pull
git fetch ... refs/changes/xx/xxxxxx/x && git checkout FETCH_HEAD # checkout A from Gerrit
git switch -c br_a
git fetch ... refs/changes/xx/xxxxxx/y && git checkout FETCH_HEAD # checkout B from Gerrit
git switch -c br_b
現在,我有兩個本地分支br_aand br_b,其中包含更改A和B.
然后我切換到我自己的本地分支,其中包含我自己的更改:git checkout br_c.
之后,我會合并 和 的更改git merge br_a到我的本地分支中。(我解決了所有的沖突。)git merge br_bABbr_c
然后我需要將所有這些推送給 Gerrit。
所以我執行git commitand git push origin HEAD:refs/for/master。
但是,我得到了錯誤。
remote: Resolving deltas: 100% (26/26)
remote: Processing changes: refs: 1, done
remote:
remote: ERROR: In commit 1111111098b751266c11111222222a33ce0b83
remote: ERROR: author email address [email protected]
remote: ERROR: does not match your user account.
remote: ERROR:
remote: ERROR: The following addresses are currently registered:
remote: ERROR: [email protected]
remote: ERROR:
remote: ERROR: To register an email address, please visit:
remote: ERROR: http://gerrit.xxxx.yyyy.com/#/settings/contact
remote:
remote:
To http://gerrit.xxxx.yyyy.com/a/xxx_project
! [remote rejected] HEAD -> refs/for/master (invalid author)
error: failed to push some refs to 'http://gerrit.xxxx.yyyy.com/a/xxx_project'
[email protected]是兩個同事之一,所以似乎git merge將一些元資料A和/或B帶入我的本地分支,這樣我就無法推送。
我已經嘗試過git commit --amend,洗掉 Change-id 和/或重置作者和電子郵件,但這沒有幫助。
uj5u.com熱心網友回復:
Gerrit 有 2 個權限,Forge Author和Forge Committer。當您推送提交以供審核時,Gerrit 會驗證作者電子郵件和提交者電子郵件是否與您在 Gerrit 用戶名中注冊的電子郵件地址匹配。如果它們不匹配,則推送被拒絕。你曾經git merge申請過提交。作者和提交者身份行沒有更改,并且與您的不匹配。所以推送失敗了。
這里有2個解決方案。一種是要求 Gerrit 管理員授予您 2 個權限,以便您可以推送其他人所做的提交。另一種是在不保留作者和提交者身份的情況下通過手動修改檔案來應用git merge --squash補丁。git cherry-pick -ngit apply
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/453495.html
