Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the Git hash of the current working directory? [duplicate]

Tags:

git

Possible Duplicate:
git hash-object on a directory?

It is said that the Git hash is a SHA-1 hash of all the files that are being tracked in that commit. It seems that we can see the hash value of the HEAD by using git rev-parse HEAD, but is there a way to see the hash value of the current working directory? (without doing a commit)

like image 730
nonopolarity Avatar asked Aug 27 '12 05:08

nonopolarity


People also ask

How do I see commit hash?

If you have the hash for a commit, you can use the git show command to display the changes for that single commit. The output is identical to each individual commit when using git log -p .

How is a git hash generated?

The first step is to reimplement Git's hash-object , as in git hash-object your_file . We create the object hash from our file by concatenating and hashing these data: The string "blob " at the beginning (mind the trailing space), followed by. the number of bytes in the file, followed by.

What is git short hash?

The short hash is just a shorter version of the original (long) hash. The original Git hash is 40 bytes long while short is only 8 bytes long. However, it becomes difficult to manage it (in terms of using typing or displaying), and that's why the short version is used.

What is a commit hash?

The commit hash is an SHA-1 hash made up of a few properties from the commit itself. As mentioned above, it is a lot more complex than this post can go into, but understanding the fundamentals is a great first step. The git hash is made up of the following: The commit message. The file changes.


1 Answers

No, because the commit ID is hashed from information based on the commit itself, such as the timestamp, description, and author names (in addition to the contents of the tree).

like image 75
Greg Hewgill Avatar answered Oct 12 '22 00:10

Greg Hewgill