I've added a file to the 'index' with:
git add myfile.java
How do I find out the SHA1 of this file?
I've added a file to the 'index' with:
git add myfile.java
How do I find out the SHA1 of this file?
$ git hash-object myfile.java
802992c4220de19a90767f3000a79a31b98d0df7
You want the -s
option to git ls-files
. This gives you the mode and sha1 hash of the file in the index.
git ls-files -s myfile.java
Note that you do not want git hash-object
as this gives you the sha1 id of the file in the working tree as it currently is, not of the file that you've added to the index. These will be different once you make changes to the working tree copy after the git add
.