git Git推送远程被拒绝{更改###关闭}
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11972384/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git push remote rejected {change ### closed}
提问by Jonathan
i am having problems pushing my changes from my local master to remote master because of this error:
由于此错误,我在将更改从本地主服务器推送到远程主服务器时遇到问题:
remote: Processing changes: refs: 1, done
To ssh://[email protected]:29418/xxxxxx
! [remote rejected] HEAD -> refs/for/master (change 14823 closed)
error: failed to push some refs to 'ssh://[email protected]:29418/xxxxxx'
any idea how i can fix this issue?
知道如何解决这个问题吗?
git status says my branch is ahead of origin/master by 5 commits.
git status 表示我的分支比 origin/master 领先 5 次提交。
回答by Johan
I got the same message. And it was because I have managed to get the same Change-Id for two commits. Maybe due to some cherry-picking or similar between my local branches. Solved by removing the Change-Id from the commit message, a new Id then was added by the commit hook.
我收到了同样的消息。这是因为我设法为两次提交获得了相同的 Change-Id。也许是由于我当地分支机构之间的一些樱桃采摘或类似行为。通过从提交消息中删除 Change-Id 来解决,然后提交钩子添加了一个新的 Id。
回答by suprith
Your Commit Change ID is expired ie, Review 14823 is closed. you can't push to same.
您的 Commit Change ID 已过期,即 Review 14823 已关闭。你不能推到相同。
Do this to fix issue:
这样做可以解决问题:
git commit --amend
- delete change id
- save and quit
- new change id will be added to the commit. it can be verified by git log.
- push again
git commit --amend
- 删除更改 ID
- 保存并退出
- 新的更改 ID 将添加到提交中。可以通过 git log 来验证。
- 再推
回答by Sterling Bourne
I found the following page which details exactly why you're unable to push your changes to the origin due to the change XXXXX closed error: https://git.eclipse.org/r/Documentation/error-change-closed.html
我找到了以下页面,其中详细说明了为什么由于更改 XXXXX 关闭错误而无法将更改推送到原点:https: //git.eclipse.org/r/Documentation/error-change-closed.html
Cheers!
干杯!
回答by user77115
You have 5 commits.
你有 5 次提交。
All of them has a file called "Commit Message" (used by Gerrit).
One of these files has a bad "Change-Id" that was already accepted
and merged into master by Gerrit, and hence cannot be used again.
他们都有一个名为“提交消息”的文件(由 Gerrit 使用)。
其中一个文件具有错误的“Change-Id”,该文件已
被 Gerrit接受并合并到 master 中,因此无法再次使用。
One fix is to merge all 5 commits into one,
and in the process of doing that,
delete the "Change-Id" in file "Commit Message".
一种解决方法是将所有 5 个提交合并为一个,
在此过程中,
删除“提交消息”文件中的“更改 ID”。
In my case, I had 3 commits, so I did:
git rebase -i HEAD~3
就我而言,我有 3 次提交,所以我做了:
git rebase -i HEAD~3
There are other ways of merging multiple commits:
Squash my last X commits together using Git
还有其他合并多个提交的方法:
使用 Git 将我最后的 X 提交压缩在一起
回答by Phil
If you have been re-basing and picked commit(s) related to review(s) that has/have been closed (merged or abandoned) in the meantime, you can simply rebase again and instead of picking, drop the commit(s) related to the review. You should then be able to push again without any issue. I strongly disagree with suggestions to play/modify Change-Ids. Detailing git commands, this would give:
如果您在此期间重新设定并选择了与已关闭(合并或放弃)的评论相关的提交,您可以简单地再次重新设定基准,而不是选择,删除提交与有关。然后,您应该能够再次推送而不会出现任何问题。我强烈不同意播放/修改 Change-Ids 的建议。详细说明 git 命令,这将给出:
git fetch; git rebase origin/a_branch --interactive
Picking every commit... Fixing conflicts and then git add ...
选择每个提交...修复冲突,然后 git add ...
git rebase --continue
git push origin HEAD:refs/for/refs/heads/a_branch
-> remote rejected... change ### closed
- >远程拒绝...更改###关闭
Then do the following:
然后执行以下操作:
git fetch; git rebase origin/a_branch --interactive
picking (pick) every commit except those related to change ### that should be dropped (drop). You should not have any conflict and get a rebase successfull right-away (conflicts were already solved in the previous rebase). Then:
挑选(挑选)每个提交,除了那些与更改### 相关的应该删除(删除)的提交。您不应该有任何冲突并立即成功获得 rebase(冲突已在之前的 rebase 中解决)。然后:
git push origin HEAD:refs/for/refs/heads/a_branch
回答by twalberg
The change 14823 closed
message does not come from vanilla git
. It indicates that whoever maintains that repository has an update or post-update hook that is evaluating your push and rejecting it due to local policy (I'm guessing you're adding additional commits to an issue that has already been marked as completed/closed). You'll need to find out what those policies are, and whether you need to somehow get the change re-opened so you can add commits to it, or if you need to create a new change request and (probably) rebase your work against it.
该change 14823 closed
消息并非来自香草git
。它表明维护该存储库的任何人都有一个更新或更新后挂钩,该挂钩正在评估您的推送并由于本地政策而拒绝它(我猜您正在向已标记为已完成/关闭的问题添加额外的提交)。您需要找出这些策略是什么,以及是否需要以某种方式重新打开更改以便向其添加提交,或者是否需要创建新的更改请求并(可能)重新调整您的工作它。
回答by David Pursehouse
git status says my branch is ahead of origin/master by 5 commits.
all im doing is fetching latest code. doing some tweaks and pushing it.
git status 表示我的分支比 origin/master 领先 5 次提交。
我所做的就是获取最新的代码。做一些调整并推动它。
What are those 5 commits? Are they all yours?
那 5 个提交是什么?他们都是你的吗?
Does change 14823 correspond to one of those 5 commits? What's its status in Gerrit?
更改 14823 是否对应于这 5 个提交之一?它在 Gerrit 中的地位如何?
回答by Hazhir
in my case I had 2 commits, the first commit was mine but second one wasn't, so I fix it this way:
在我的情况下,我有 2 个提交,第一个提交是我的,但第二个不是,所以我这样修复它:
- find out which files were committed in change 14823
- find your oldest commit and do a softreset to its parent. be aware, if you do a hard reset you may lose all your commits.
- try to commit your changes one more time but in this time without the files from change 14823
- 找出在更改 14823中提交的文件
- 找到最旧的提交并对其父项进行软重置。请注意,如果您进行硬重置,您可能会丢失所有提交。
- 尝试再次提交您的更改,但这次没有更改 14823 中的文件
I hope it's helpful.
我希望它有帮助。
回答by keylan
Try this. git push --no-thin origin xxxxxx:refs/for/sprint/yyyyyy
尝试这个。git push --no-thin origin xxxxxx:refs/for/sprint/yyyyyy
回答by ebneter
You're pushing to gerrit, which is a code review tool, as indicated by both the url (ssh://[email protected]:29418/xxxxxx) and the "HEAD -> refs/for/master" message. You need to consult with whoever maintains the repository you're trying to push to in order to figure out why the change is being rejected.
您正在推动 gerrit,这是一个代码工具,如 url (ssh://[email protected]:29418/xxxxxx) 和“HEAD -> refs/for/master”所示“ 信息。您需要咨询维护您尝试推送到的存储库的任何人,以找出更改被拒绝的原因。