How to Add a New Commit To 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 testtest$ 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 plantest$ git commit -m"Start test plan."[master 7fd2d16] Start test plan. Committer: Tim Flagg <@gitguys.com> 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 --abbrev100644 bccdfbd 0 README100644 ddd8641 0 docs/hello100644 6403d7d 0 src/hello.c100644 dd7a98c 0 src/hello.py100644 cdf672b 0 test/plan

Find out the git tree from the most recent commit:

test$ git cat-file -p HEADtree a8e36bc5462f60cd970dfb86f8bbfee759c1a247parent 126af200bf65ace0ea07950db4c02241a2f6fa1fauthor Tim Flagg <me@gitguys.com> 1297823001 -0800committer Tim Flagg <me@gitguys.com> 1297823001 -0800Start test plan.

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

test$ git ls-tree a8e36 --abbrev100644 blob bccdfbd README040000 tree 31b11e8 docs040000 tree 05f8c83 src040000 tree 952432e test

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

Related:

The Git Tree Object
The Git Commit Object
The Git Tag Object
The Git Blob Object
All Git Object Types: Blob, Tree, Commit And Tag
What Is The Format Of A Git Blob?

Recent Articles

Where Do I Get Git?

Where do you get git? We have the answer to that for Linux (Ubuntu, Debian, and Red Hat), Windows, and Apple OS as well as over 30 free git tutorials.

What is the deal with the Git Index? What is the Git Index?

The git "index" is where you place files you want committed to the git repository. Learn more about the git index and git commit by selecting this link.

What Every VCS Must do

Version Control System ("VCS") need to be able to provide to its users? GitGuys explains exactly what it needs to include and provides tutorials on Git.

Visualising Branches And Their Commits

We explain and discuss the use of the git show-branch, gitg, gitk and qgit in this Tutorial. Complete with examples.

“Tracking Branches” And “Remote-Tracking Branches”

Both Tracking Branches and Remote Tracking Branches are created on the git client when a git clone command is used.

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here

Stay on op - Ge the daily news in your inbox