Book Image

Git Version Control Cookbook

By : Aske Olsson, Rasmus Voss
Book Image

Git Version Control Cookbook

By: Aske Olsson, Rasmus Voss

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 blob object to the database


In this example, we'll see how we can use plumbing commands to add blob objects to the database. This is, of course, used internally by the git add command; however, this can also be useful if you, for example, need to add the public part of your GPG key to the Git repository so that signed tags can be verified. You can then, after you've added the key, tag the blob ID so that the other committers can find it.

Getting ready

We'll create and use a new repository for this example and the next couple of examples. Let's create a new repository in the myplumbing folder:

$ git init myplumbing
Initialized empty Git repository in /path/to/myplumbing/.git/
$ cd myplumbing
$ git status
On branch master

Initial commit

nothing to commit (create/copy files and use "git add" to track)

How to do it...

Git uses the hash-object plumbing command to write objects to its database. We can use it to update the database with the content of files, or pass the content directly...