Gerrit:添加/提交到本地git repo后,我收到:[尝试删除远程](未进行任何更改),但尝试将其推送到远程 [英] Gerrit: after add/commit to local git repo, I receive: [remote rejected] (no changes made) when trying to push to remote

查看:100
本文介绍了Gerrit:添加/提交到本地git repo后,我收到:[尝试删除远程](未进行任何更改),但尝试将其推送到远程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是尝试推送到远程git repo时的输出:

The following is the output when trying to push to remote git repo:

Counting objects: 28, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (26/26), done.
Writing objects: 100% (28/28), 3.28 KiB | 1.64 MiB/s, done.
Total 28 (delta 22), reused 0 (delta 0)
remote: Resolving deltas: 100% (22/22)
remote: Processing changes: refs: 1, done
remote: (W) No changes between prior commit 4075c99 and new commit bbb6b31
To http://172.16.0.5:8080/chef-repo
 ! [remote rejected] HEAD -> refs/for/chef-feature-1.0 (no changes made)
error: failed to push some refs to 'http://172.16.0.5:8080/chef-repo'

注意:在此之前,我已经修改了我的最后一次提交

Note: before hand, I had amended my last commit

我看到所做的更改在提交时被确认,所以我不明白为什么我不能推送它们.

I see the changes are acknowledged when a commit so I do not understand why I cannot push them.

git diff 4075c99 bbb6b31 没有显示输出,我整天都在提交东西,最后一次使用Gerrit的时间是20日(本地大约30分钟前).

git diff 4075c99 bbb6b31 displays no output put I have been commiting things all day and the last push on gerrit was on the 20th (locally it was like 30 min ago).

这是我当前的 git log 输出:

commit 8e3b769cf035a304d4b5bd796fd13737efaba01a (HEAD -> chef-feature-1.0)
Author: Aaron West <aaron.west@accenture.com>
Date:   Fri Dec 22 09:51:06 2017 -0600

    finalized oid1

    Change-Id: I1b2449a74a86aa5f02a75f5c768203a24860dfe1

commit 12b082629bfd14e63a7dca8a5c43f41db23ca64b
Author: Aaron West <aaron.west@accenture.com>
Date:   Fri Dec 22 09:49:01 2017 -0600

    cleaned up the oid.erb

    Change-Id: I0b906bbcb4b7b25bac41524b96d5133965ea93ea

推荐答案

Gerrit拒绝您的推送,因为 4075c99 bbb6b31 是具有不同哈希值的相同提交.

Gerrit is rejecting your push because 4075c99 and bbb6b31 are identical commits with different hashes.

最常见的发生方式是修改提交(创建新的提交哈希)但实际上不做任何更改:

The most common way that this happens is when you amend a commit (creating a new commit hash), but don't actually change anything:

$ git push origin HEAD:refs/for/master
$ git commit --amend
... don't make any changes ...
$ git push origin HEAD:refs/for/master

但是,这不是 only 发生的方式.即使您最近的提交实际上包含有效的更改,在其他情况下也会产生类似的错误.例如,如果您前面有两个提交(两个未合并的Gerrit更改集),并且您对最近的提交进行了更改,但不小心以某种方式更改了先前的哈希(通常是在经过修改的提交上进行樱桃选择,或者使用重置-i ):

However, that's not the only way it can happen. There are other scenarios that will produce a similar error even though your most recent commit actually contains valid changes. For example, if you're two commits ahead (two unmerged Gerrit change sets), and you make changes to the most recent commit, but accidentally change the previous hash somehow (often with cherry-picking over an amended commit or with rebase -i):

... two commits ahead of Gerrit ...
$ git checkout HEAD~1
$ git commit --amend
... don't make any changes ...
$ git cherry-pick master
... make some valid changes that you want to push ...
$ git commit --amend
$ git push origin HEAD:refs/for/master
REMOTE REJECTED!

您可能会遇到这种情况(可能比2次提交要深),因为日志中最近2次提交都没有Gerrit抱怨的哈希值.

This is likely the case for you (and it may be deeper than 2 commits) because neither of the 2 most recent commits in your log have the hash that Gerrit is complaining about.

无论您是如何遇到这种情况的,解决方案都应该相同:获取 Gerrit的版本(精确的哈希匹配)承诺它正在抱怨,并在此基础上挑选您的工作.在您的示例中,先前的提交为 4075c99 :

Regardless of how you arrived at this situation, the solution should be the same: Get Gerrit's version (exact hash match) of the commit it's complaining about and cherry-pick your work on top of it. With your example, the prior commit is 4075c99:

$ git checkout 4075c99
$ git cherry-pick <changes you want>
$ git push origin HEAD:refs/for/master

这篇关于Gerrit:添加/提交到本地git repo后,我收到:[尝试删除远程](未进行任何更改),但尝试将其推送到远程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆