簡體   English   中英

使用'git cat-file -p'時,子模塊提交對象'不是有效的對象名'

[英]Submodule commit object 'Not a valid object name' when using 'git cat-file -p'

我已經對git內部和其他git對象更加熟悉了。 我有一個簡單的存儲庫,在頂層目錄中有一個.txt文件,在名為“ my-directory”的目錄中有兩個.txt文件(file1.txt和file2.txt),還有一個名為“ my-submodule”的子模塊。 當我嘗試運行$ git cat-file -p {submodule git commit object SHA-1} ,但我無法弄清原因。 我在下面顯示了我正在運行的所有命令,希望有人能幫助我。

$ git cat-file -p master
tree fcc88590212b42b31803217036a93a9edfe4af1c
parent ae767cc2edd396e63f127d4f3354f769645a3dc4
author Martin
committer Martin

Awesome commit


$ git cat-file -p fcc88590212b42b31803217036a93a9edfe4af1c
100644 blob 21735012b86a0c6c266eb7fb629a777ca70848c1  my-file.txt
040000 tree 4df930165b3c59c0f5dc134ed76d889e4d177d2f my-directory
160000 commit 93a431b481f9ca2b498c94b0c0641e54f00322e0 my-submodule

$ git cat-file -p 21735012b86a0c6c266eb7fb629a777ca70848c1
This is the content of 'my-file.txt'

$ git cat-file -p 4df930165b3c59c0f5dc134ed76d889e4d177d2f 
100644 file1.txt
100644 file2.txt

$ git cat-file -p 93a431b481f9ca2b498c94b0c0641e54f00322e0
fatal: Not a valid object name 93a431b481f9ca2b498c94b0c0641e54f00322e0

cat-file向您顯示當前存儲庫中的對象,但子模塊是單獨的存儲庫。 因此,提交ID 93a43…是來自其他對象存儲的提交。 您應該導航到子模塊的目錄,然后從那里嘗試:

$ cd my-submodule
$ git cat-file -p 93a431b481f9ca2b498c94b0c0641e54f00322e0

我想象git會發現某個特定的樹條目是按對象類型划分的子模塊。 即,如果輸入類型為:

  • “斑點”-只是一個文件,
  • “樹”-它是一個子目錄,
  • “提交”它是一個子模塊。

暫無
暫無

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

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