Book Image

Git Version Control Cookbook

Book Image

Git Version Control Cookbook

Overview of this book

Table of Contents (19 chapters)
Git Version Control Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Writing a tree object to the database


Now, we have manually created objects in the Git database, but as nothing point to these objects, we have to remember them by their SHA-1 identifier. Furthermore, only the content of the files is stored in the database, so we learn to create a tree object that will refer to the blobs created.

Getting ready

We'll use the same repository of the last examples with the objects we created in the database.

How to do it...

We'll start by adding the first version of mytest.txt as follows:

$ git update-index --add --cacheinfo 100644 \
926e8ffd3258ed6edd1e254438f02fd24e417acc mytest.txt

Now we can write the content of the staging area to the database:

$ git write-tree
4c4493f8029d491d280695e263e24772ab6962ce

We can update and write a tree for the second version of mytest.txt as follows:

$ git update-index --cacheinfo 100644 \
6b3da706d14c3820597ec7109f163bc144dcbb22 mytest.txt
$ git write-tree
2b9697438318f3a62a5e85d14a3b52d69b962907

Finally, we can use the object...