为什么我得到 "Error failed to push some refs"?
Why am I getting "Error failed to push some refs"?
我正在将 Git 与 Gerrit 一起使用,并尝试使用以下命令推送更改
git push origin HEAD:refs/for/master
失败并显示以下错误消息
Counting objects: 54, done. Delta compression using up to 4 threads.
Compressing objects: 100% (23/23), done. Writing objects: 100%
(54/54), 4.56 KiB | 0 bytes/s, done. Total 54 (delta 20), reused 0
(delta 0) remote: Resolving deltas: 100% (20/20) remote: Processing
changes: refs: 1, done remote: ERROR: [041a9f9] missing Change-Id in
commit message footer remote: remote: Hint: To automatically insert
Change-Id, install the hook: remote: gitdir=$(git rev-parse
--git-dir); scp -p -P 29418 urid@gerrit.ext.net.something.com:hooks/commit-msg ${gitdir}/hooks/
remote: And then amend the commit: remote: git commit --amend
remote: To ssh://gerrit.ext.net.something.com:29418/Project/FolderName
! [remote rejected] HEAD -> refs/for/master ([041a9f9] missing
Change-Id in commit message footer) error: failed to push some refs to
'ssh://username@gerrit.ext.net.something.com:29418/Project/FolderName'
因此,如上面错误消息中所述,我 运行 下面的命令
--git-dir); scp -p -P 29418 urid@gerrit.ext.net.something.com:hooks/commit-msg ${gitdir}/hooks/
输出为
commit-msg
100% 4682 23.0KB/s 00:00
所以这意味着在我 运行 命令
之后钩子在我的项目工作目录中正确下载
git commit --amend
它显示正确的 Change-Id: I55862204ef71f69bc88c79fe2259f7cb8365699a
并且如本文所述 documents 它仅在最后一行。
但我仍然无法推送我试图从中获得帮助的更改 question 但它仍然失败并显示相同的消息。
更新 1
这是
的输出
$ git log
commit 10690fb1b829981852855aecaab0dfd7aaf9997f (HEAD -> master)
Author: Author Name
Date: Wed Jun 6 18:42:25 2018 +0530
SUREREQ-6877:Support of PATCH and OPTIONS
Change-Id: Ic7f36b90832078afa740b1138cb35829456f389d
commit 041a9f9deeae886c9771995a1463d40ca2d3fa3c Merge: e265b88b
7f2ec936 Author: Author Name Date: Wed Jun 6 17:33:48 2018 +0530
Merge branch 'master' of ssh://gerrit.ext.net.nokia.com:29418/SURE/sure-sw
commit e265b88b6194f65dedbf070b2be7f6c7018f6dec Author: Author Name
Date: Wed Jun 6 16:59:58 2018 +0530
SUREREQ-6877:Support of PATCH and OPTIONS
Change-Id: I82382926d5acd8f9101bd3fc7bbb33bae85672da
commit 7603b20691b59de2f086ca5633314f89bcc963ab Author: Author Name
Date: Wed Jun 6 16:53:04 2018 +0530
SUREREQ-6877:Support of PATCH and OPTIONS
Change-Id: I9312ebbe3d346ff97ca996c2219f204a55d1b9ac
commit 305fd46084f2a230f96b316f814ebf0eabd849c2 Author: Author Name
Date: Wed Jun 6 16:52:24 2018 +0530
SUREREQ-6877:Support of PATCH and OPTIONS
Change-Id: I011e3e3c22954774e99462c585a54cf9a0aad428
commit 8b1059922745a605851f4a9bd6cae3193a85c62c Author: Author Name
Date: Wed Jun 6 16:49:15 2018 +0530
SUREREQ-6877:Support of PATCH and OPTIONS
Change-Id: Ic9d9e7e787f8a826f18f361cf0c20930c42bf04b
commit 7f2ec936f4133988194b14dca910fb921a6946be (origin/master,
origin/HEAD)
看来问题不在上次commit。问题(缺少的 Change-Id)可能出在父提交上。执行 git log
命令并检查您的提交历史,查找没有 Change-Id 的任何新提交。请记住:所有新提交都必须具有唯一的 Change-Id。如果是这种情况,您需要使用 git rebase -i
命令将 Change-Id 添加到提交中。
您的提交 041a9f9deeae886c9771995a1463d40ca2d3fa3c
是一个合并提交,它没有 Change-ID。这可能是在本地创建的,Git 不会 运行 合并提交的 commit-msg 挂钩。您需要确保在提交更改之前解决此问题。
尝试 git pull origin -r master
展平合并提交,其中缺少 Change-Id
。合并提交是多余的。
我正在将 Git 与 Gerrit 一起使用,并尝试使用以下命令推送更改
git push origin HEAD:refs/for/master
失败并显示以下错误消息
Counting objects: 54, done. Delta compression using up to 4 threads. Compressing objects: 100% (23/23), done. Writing objects: 100% (54/54), 4.56 KiB | 0 bytes/s, done. Total 54 (delta 20), reused 0 (delta 0) remote: Resolving deltas: 100% (20/20) remote: Processing changes: refs: 1, done remote: ERROR: [041a9f9] missing Change-Id in commit message footer remote: remote: Hint: To automatically insert Change-Id, install the hook: remote: gitdir=$(git rev-parse --git-dir); scp -p -P 29418 urid@gerrit.ext.net.something.com:hooks/commit-msg ${gitdir}/hooks/ remote: And then amend the commit: remote: git commit --amend remote: To ssh://gerrit.ext.net.something.com:29418/Project/FolderName ! [remote rejected] HEAD -> refs/for/master ([041a9f9] missing Change-Id in commit message footer) error: failed to push some refs to 'ssh://username@gerrit.ext.net.something.com:29418/Project/FolderName'
因此,如上面错误消息中所述,我 运行 下面的命令
--git-dir); scp -p -P 29418 urid@gerrit.ext.net.something.com:hooks/commit-msg ${gitdir}/hooks/
输出为
commit-msg
100% 4682 23.0KB/s 00:00
所以这意味着在我 运行 命令
之后钩子在我的项目工作目录中正确下载git commit --amend
它显示正确的 Change-Id: I55862204ef71f69bc88c79fe2259f7cb8365699a
并且如本文所述 documents 它仅在最后一行。
但我仍然无法推送我试图从中获得帮助的更改 question 但它仍然失败并显示相同的消息。
更新 1 这是
的输出$ git log
commit 10690fb1b829981852855aecaab0dfd7aaf9997f (HEAD -> master) Author: Author Name
Date: Wed Jun 6 18:42:25 2018 +0530
SUREREQ-6877:Support of PATCH and OPTIONS Change-Id: Ic7f36b90832078afa740b1138cb35829456f389d
commit 041a9f9deeae886c9771995a1463d40ca2d3fa3c Merge: e265b88b 7f2ec936 Author: Author Name Date: Wed Jun 6 17:33:48 2018 +0530
Merge branch 'master' of ssh://gerrit.ext.net.nokia.com:29418/SURE/sure-sw
commit e265b88b6194f65dedbf070b2be7f6c7018f6dec Author: Author Name
Date: Wed Jun 6 16:59:58 2018 +0530SUREREQ-6877:Support of PATCH and OPTIONS Change-Id: I82382926d5acd8f9101bd3fc7bbb33bae85672da
commit 7603b20691b59de2f086ca5633314f89bcc963ab Author: Author Name
Date: Wed Jun 6 16:53:04 2018 +0530SUREREQ-6877:Support of PATCH and OPTIONS Change-Id: I9312ebbe3d346ff97ca996c2219f204a55d1b9ac
commit 305fd46084f2a230f96b316f814ebf0eabd849c2 Author: Author Name
Date: Wed Jun 6 16:52:24 2018 +0530SUREREQ-6877:Support of PATCH and OPTIONS Change-Id: I011e3e3c22954774e99462c585a54cf9a0aad428
commit 8b1059922745a605851f4a9bd6cae3193a85c62c Author: Author Name
Date: Wed Jun 6 16:49:15 2018 +0530SUREREQ-6877:Support of PATCH and OPTIONS Change-Id: Ic9d9e7e787f8a826f18f361cf0c20930c42bf04b
commit 7f2ec936f4133988194b14dca910fb921a6946be (origin/master, origin/HEAD)
看来问题不在上次commit。问题(缺少的 Change-Id)可能出在父提交上。执行 git log
命令并检查您的提交历史,查找没有 Change-Id 的任何新提交。请记住:所有新提交都必须具有唯一的 Change-Id。如果是这种情况,您需要使用 git rebase -i
命令将 Change-Id 添加到提交中。
您的提交 041a9f9deeae886c9771995a1463d40ca2d3fa3c
是一个合并提交,它没有 Change-ID。这可能是在本地创建的,Git 不会 运行 合并提交的 commit-msg 挂钩。您需要确保在提交更改之前解决此问题。
尝试 git pull origin -r master
展平合并提交,其中缺少 Change-Id
。合并提交是多余的。