簡體   English   中英

Git pre-receive hook newRev 問題

[英]Git pre-receive hook newRev issue

在執行前收到鈎git show $newrev節目中DIFF $newRev但如果在執行pre-receive勾我會去回購和執行相同的命令git show $newrev它會返回錯誤fatal: bad object {newRev}

Git 版本:2.22.0。 在 Git 2.7.4 git show在 repo 中執行git show不會返回錯誤。

git show正常工作時pre-receive hook script

#!/usr/bin/env bash
read oldrev newrev refname

git show $newrev

pre-receive hook script帶有睡眠的pre-receive hook script並在 repo 中手動運行git show

#!/usr/bin/env bash
read oldrev newrev refname

sleep 999
cd /repo
git show ae435ae1f9de55620d306cc82799ff20870f4238

致命:壞對象ae435ae1f9de55620d306cc82799ff20870f4238

經過調查,我了解到pre-receive鈎子中的 Git 創建了單獨的臨時目錄,它收集有關提交的信息。 例如臨時目錄名稱是objects/incoming-GsAsa

但是 Git 只在pre-receive鈎子腳本中知道它,因為它正確設置了GIT_OBJECT_DIRECTORYGIT_ALTERNATE_OBJECT_DIRECTORIES環境。

因此,問題的答案是正確設置GIT_OBJECT_DIRECTORYGIT_ALTERNATE_OBJECT_DIRECTORIES變量。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM