git 錯誤訊息「伺服器不允許請求未通告的物件」是什麼意思?

git 錯誤訊息「伺服器不允許請求未通告的物件」是什麼意思?

我嘗試從 github 進行結帳,但收到以下錯誤訊息:

[user@arch ~]$ git clone --recursive https://github.com/simsong/tcpflow.git
Cloning into 'tcpflow'...
The authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
remote: Counting objects: 4190, done.
remote: Compressing objects: 100% (32/32), done.
remote: Total 4190 (delta 21), reused 29 (delta 12), pack-reused 4146
Receiving objects: 100% (4190/4190), 50.27 MiB | 2.21 MiB/s, done.
Resolving deltas: 100% (2954/2954), done.
Submodule 'src/be13_api' (https://github.com/simsong/be13_api.git) registered for path 'src/be13_api'
Submodule 'src/dfxml' (https://github.com/simsong/dfxml.git) registered for path 'src/dfxml'
Submodule 'src/http-parser' (https://github.com/nodejs/http-parser.git) registered for path 'src/http-parser'
Cloning into '/home/user/tcpflow/src/be13_api'...
remote: Counting objects: 1203, done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 1203 (delta 2), reused 5 (delta 1), pack-reused 1194
Receiving objects: 100% (1203/1203), 477.47 KiB | 1.96 MiB/s, done.
Resolving deltas: 100% (821/821), done.
Cloning into '/home/user/tcpflow/src/dfxml'...
remote: Counting objects: 1929, done.
remote: Total 1929 (delta 0), reused 0 (delta 0), pack-reused 1929
Receiving objects: 100% (1929/1929), 572.09 KiB | 2.89 MiB/s, done.
Resolving deltas: 100% (1294/1294), done.
Cloning into '/home/user/tcpflow/src/http-parser'...
remote: Counting objects: 1487, done.
remote: Total 1487 (delta 0), reused 0 (delta 0), pack-reused 1487
Receiving objects: 100% (1487/1487), 667.24 KiB | 2.46 MiB/s, done.
Resolving deltas: 100% (916/916), done.
Submodule path 'src/be13_api': checked out 'c81521d768bb78499c069fcd7c47adc8eee0350c'
Submodule path 'src/dfxml': checked out 'c31224626cf5f6678d42cbcfbfcd4e6191c9a864'
error: Server does not allow request for unadvertised object 5bbcdc5df9d01b521e8da011bab0da70bdec3653
Fetched in submodule path 'src/http-parser', but it did not contain 5bbcdc5df9d01b521e8da011bab0da70bdec3653. Direct fetching of that commit failed.
[user@arch ~]$

所以我是這些儲存庫的維護者。 src/http-parser 是另一個儲存庫的分支,該儲存庫的維護者始終不接受我的拉取請求(沒有給出任何原因)以將一些自動產生的檔案新增至檔案.gitignore。但我認為這不是問題所在。

答案1

jgit - git 的廣告參考是什麼? - 堆疊溢位:

在獲取期間,伺服器可以列出它擁有的以及客戶端可能想要獲取的引用。這些都是廣告中的參考資料。

  • 看起來像您無法直接從伺服器取得任何單一特定提交,只能取得引用(即分支和標籤)。或者更確切地說,Github 伺服器被配置為不允許此類請求。
  • 所以,如果你想獲得特定的提交--depth,它必須至多<depth>-1提交遠離獲取的引用(這是子模組元資料中指定的分支/標籤)

    通常,人們建議設定depth為某個相當大的數字,但仍然比儲存庫中的提交總數小得多——例如50100。例如,50Travis 在為專案進行初始克隆時使用的。

如果您不使用 更新子模組--depth,則找不到提交將意味著:

  • 子模組的樹處於“淺”狀態並且上述內容適用(僅當之前使用--depth或更新時才可能)它的條目.gitmodulesshallow = true
  • 提交不在子模組正在使用的分支上
  • 提交根本不在子模組的儲存庫中:
    • 要么有人犯了錯誤,
    • 或曾經存在但被強制推送刪除

根據記錄,在您的具體情況下,這是最後一種情況:提交根本5bbcdc5df9d01b521e8da011bab0da70bdec3653不在https://github.com/simsong/http-parser.git儲存庫中。

答案2

存取未公佈的物件的一種方法是同步。然後子模組更新應該可以工作,例如:

git submodule sync --recursive
git submodule update

答案3

當您指向已透過歷史記錄重寫或壓縮刪除的子模組提交時,可能會發生這種情況。你能做的最好的事情是:

  • 首先清楚地了解您的團隊一直在做什麼,這樣您就知道它應該是什麼樣子。
  • 使用 git pull 更新本機,然後找到與您的分支最接近的提交(可能是最新的),然後將其新增至您的父儲存庫。例如:
parent-repo$ git fetch
parent-repo$ cd submodule-a
submodule-a$ git pull
submodule-a$ git checkout best-commit-according-to-team-and-your-branch
submodule-a$ cd ../
parent-repo$ git status
...
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)
        modified:  submodule-a (modified content)
...
git add submodule-a
git commit -m "updated submodule-a reference"

一旦您感到高興,它是正確的,並且您的團隊同意您可以將其推高,錯誤就會消失。

答案4

對我來說,當我將父 git 儲存庫推回 github 而不推回我已修改和提交但尚未推回的子模組時,往往會發生這種情況。

相關內容