gpt4 book ai didi

git - Gerrit:添加/提交到本地 git repo 后,我收到:尝试推送到远程时 [remote rejected] (no changes made)

转载 作者:行者123 更新时间:2023-12-04 16:08:03 25 4
gpt4 key购买 nike

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

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'

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

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

git diff 4075c99 bbb6b31 显示没有输出我一整天都在提交东西,最后一次推送 gerrit 是在 20 号(本地好像是 30 分钟前)。

这是我当前的 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 拒绝您的推送,因为 4075c99bbb6b31具有不同哈希值的相同提交

发生这种情况的最常见方式是当您修改提交(创建新的提交哈希)但实际上不更改任何内容时:

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

但是,这不是唯一发生的方式。还有其他情况会产生类似的错误,即使您最近的提交实际上包含有效更改。例如,如果您前面有两个提交(两个未 merge 的 Gerrit 更改集),并且您对最近的提交进行了更改,但不小心以某种方式更改了先前的哈希值(通常对修改后的提交进行挑选或使用 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 提示的哈希值。

不管您是如何遇到这种情况的,解决方案应该是相同的:获取 Gerrit 的 版本(完全哈希匹配)提交它的提示并在它之上挑选你的工作。对于您的示例,先前的提交是 4075c99:

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

关于git - Gerrit:添加/提交到本地 git repo 后,我收到:尝试推送到远程时 [remote rejected] (no changes made),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47946653/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com