Adding a New Commit To The Git Object Store

Creating the sample working directory and placing it into the git
object store

The below shows how the file and directory were created and added to the git object store that is discussed in Git object: Commit.

This example continues on from the Git Object Tree example.

Create the new directory and file:

$ mkdir test
$ cd test
test$ echo This is my test plan > plan

Add the new file to git (its new parent directory automatically gets added to git when the new file is added):

test$ git add plan
test$ git commit -m"Start test plan."
[master 7fd2d16] Start test plan.
 Committer: Tim Flagg <>
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 test/plan

Find out out the hashes of the files (though this does not display the hashes of the trees):

test$ git ls-files --stage --abbrev
100644 bccdfbd 0    README
100644 ddd8641 0    docs/hello
100644 6403d7d 0    src/hello.c
100644 dd7a98c 0    src/
100644 cdf672b 0    test/plan

Find out the git tree from the most recent commit:

test$ git cat-file -p HEAD
tree a8e36bc5462f60cd970dfb86f8bbfee759c1a247
parent 126af200bf65ace0ea07950db4c02241a2f6fa1f
author Tim Flagg <> 1297823001 -0800
committer Tim Flagg <> 1297823001 -0800

Start test plan.

List the contents of that commit’s tree (hash a8e36):

test$ git ls-tree a8e36 --abbrev
100644 blob bccdfbd README
040000 tree 31b11e8 docs
040000 tree 05f8c83 src
040000 tree 952432e test

Next: The Git Tag Object
Previous: The Git Commit Object