I’ve added a file to the ‘index’ with:
git add myfile.java
How do I find out the SHA1 of this file?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You want the
-soption togit ls-files. This gives you the mode and sha1 hash of the file in the index.Note that you do not want
git hash-objectas 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 thegit add.