git hash-object
is used to compute the SHA hash of a Git object
$ echo "hello world" > test.txt
$ git hash-object test.txt
3b18e512dba79e4c8300dd08aeb37f8e728b8dad
When using with -w
, it also writes the object to .git/objects
$ git hash-object -w test.txt
# Verify that the file was written to .git/objects
$ file .git/objects/3b/18e512dba79e4c8300dd08aeb37f8e728b8dad
.git/objects/3b/18e512dba79e4c8300dd08aeb37f8e728b8dad: zlib compressed data
Related
- git cat-file: view content of a git object