Low Level Commands
Git has a set of commands that translate between the git hash-based organization of content and the repository file system. This is possible because of the magical one-to-one correspondence between a file’s contents and its SHA1 key.
To view the contents of a blob in the repository from its SHA1 key:
$ git cat-file -p <SHA1-key>
The inverse lookup, to find a SHA1 key from a tag, file-name? etc.$ git rev-parse
To run the SHA1 hash on content$ git hash-object
To see the correspondence in the index between files and their keys.
$ git ls-files --stage
Day-to-day commands are composed of lower-level commands such as these that are exposed to create
To create a tree node from the current index:
$ git write-tree
The SHA1 key returned for the tree is used to write a commit node to stdout:
$ git commit-tree git write-tree -m"Here is a commit node"
Human readable git objects:$ git show
The inverse of$ git rm –cached
git add, to unstage a file (remove it from the index) without reverting to the previous committed version:
In general the
--cached switch applies the command to the index.
To see the sequence in the log on a file that has been moved or renamed:$ git log –follow
J. Loeliger & m. McCullough, “Git” O’Reilly 2012. ↩