git-tree哈希不显示Blob



我执行了git提交,并成功地将文件推送到远程repo。在检查提交的git树时,没有找到提交到git的blob哈希。

Shalabh@LAPTOP-O9UDCPOI MINGW64 ~/IdeaProjects/gittest/src/main/resources (master)
$ vi second-file.txt
Shalabh@LAPTOP-O9UDCPOI MINGW64 ~/IdeaProjects/gittest/src/main/resources (master)
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
second-file.txt
nothing added to commit but untracked files present (use "git add" to track)
Shalabh@LAPTOP-O9UDCPOI MINGW64 ~/IdeaProjects/gittest/src/main/resources (master)
$ git add .
warning: LF will be replaced by CRLF in src/main/resources/second-file.txt.
The file will have its original line endings in your working directory
Shalabh@LAPTOP-O9UDCPOI MINGW64 ~/IdeaProjects/gittest/src/main/resources (master)
$ git commit
[master 3fb459d] Git Commit#2
1 file changed, 1 insertion(+)
create mode 100644 src/main/resources/second-file.txt
Shalabh@LAPTOP-O9UDCPOI MINGW64 ~/IdeaProjects/gittest/src/main/resources (master)
$ git status
On branch master
nothing to commit, working tree clean
Shalabh@LAPTOP-O9UDCPOI MINGW64 ~/IdeaProjects/gittest/src/main/resources (master)
$ git push --set-upstream origin master
Enumerating objects: 10, done.
Counting objects: 100% (10/10), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (6/6), 497 bytes | 497.00 KiB/s, done.
Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
To https://gitlab.com/shalabh_chaturvedi/gittest.git
8d6d403..3fb459d  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
Shalabh@LAPTOP-O9UDCPOI MINGW64 ~/IdeaProjects/gittest/src/main/resources (master)
$ git log
commit 3fb459d6a2104d8335e27b45b8f79f20aca78428 (HEAD -> master, origin/master)
Author: Shalabh Chaturvedi <shalabhchaturvedi@icloud.com>
Date:   Tue Aug 4 01:11:59 2020 +0530
Git Commit#2
Add second file with some git commands
commit 8d6d403def38cf8b611b14823d15455b4dc20c5a
Author: shalabh chaturvedi <shalabhchaturvedi@icloud.com>
Date:   Sat Aug 1 22:14:40 2020 +0530
Commit id #1
Create a file Intro.txt with content 'Hello git'
Shalabh@LAPTOP-O9UDCPOI MINGW64 ~/IdeaProjects/gittest/src/main/resources (master)
$ git cat-file -p 3fb459d6a2104d8335e27b45b8f79f20aca78428
tree 93fc6f1481138e1d2de420f2d834a1c8b02a9259
parent 8d6d403def38cf8b611b14823d15455b4dc20c5a
author Shalabh Chaturvedi <shalabhchaturvedi@icloud.com> 1596483719 +0530
committer Shalabh Chaturvedi <shalabhchaturvedi@icloud.com> 1596483719 +0530
Git Commit#2
Add second file with some git commands
Shalabh@LAPTOP-O9UDCPOI MINGW64 ~/IdeaProjects/gittest/src/main/resources (master)
$ git cat-file -p 93fc6f1481138e1d2de420f2d834a1c8b02a9259
100644 blob 70ebc1f9607fab6ed8fc5fa58f0f582716f07f50    pom.xml
040000 tree 01267bfb4ca46c032b5ed7954be3e3c72630d0fe    src

在gitlab帐户中,我可以看到提交后附加的"second-file.txt"。我是否使用了任何错误的命令,或者是否有其他方法可以将文件附加到树哈希中。

感谢您的回复。

您在src:内部进行了挖掘

git cat-file -p 01267bfb4ca46c032b5ed7954be3e3c72630d0fe

使用将为main显示的id:

git cat-file -p the-id-for-main

使用资源id:

git cat-file -p the-id-for-resources

然后,您将看到第二个文件.txt的blob的id…或在一个快照中:

git cat-file -p 3fb459d6a2104d8335e27b45b8f79f20aca78428:src/main/resources

最新更新