x
Loading
 Loading
Hello, Guest | Login | Register

Embracing the Git Index

Linus Torvalds once said, “If you deny the Index, you really deny git itself.” (February 4, 2006, Git List Archives). Rather than try to sweep the mysteries and complexities of the git Index under the rug, some explanation and examples can help clarify it, expose its power, and allow you to revel in it!

There are several articles that provide background information about git. The impetus for the software’s creation and some of the early history of its development are covered in Sam Williams’s article “Git With It!” in the August 2005 issue of Linux Magazine. The first part of this series, “How to Git It”, explains how to obtain and install git, and introduces the basics of git’s Object Database and Index.

In this second part of the series, let’s look more at the Index. The Index is fundamental to git, and provides the basis for almost every operation, simple or complex, that git provides. Let’s create a project, follow the code through several revisions implemented by two independent developers, and finally unify the results. Along the way, the subtle yet powerful operations within the git Index will be explained.

Creating a Project With git

The simplest way to create a new project using git is to use the git init-db command. The command can be used to either create a brand new repository for new development, or can be used on a snapshot of an existing source tree to turn it into a git repository.

Here is a quick-and-dirty prime number program written in C. Never mind that it has issues — those will be fixed soon enough. Before making any modifications, place it under source control with git init-db.

 $ pwd /usr/src/primes...

Please log in to view this content.

Not Yet a Member?

Register with LinuxMagazine.com and get free access to the entire archive, including:

  • Hands-on Content
  • White Papers
  • Community Features
  • And more.
Already a Member?
Log in!
Username

Password

Remember me

Forgotten your password?
Forgotten your username?
Read More
  1. Helpful Tools for Software Developers
  2. The Github Hall of Fame
  3. Book'em, Github.
  4. This Week on Github: Stupid Ruby Tricks
  5. A Veritable Scatter Shot!
Follow Linux Magazine
Rackspace