README.md

Grit

Grit gives you object oriented read/write access to Git repositories via Ruby.
The main goals are stability and performance. To this end, some of the
interactions with Git repositories are done by shelling out to the system's
git command, and other interactions are done with pure Ruby
reimplementations of core Git functionality. This choice, however, is
transparent to end users, and you need not know which method is being used.

This software was developed to power GitHub, and should be considered
production ready. An extensive test suite is provided to verify its
correctness.

Source

Development

You will need these gems to get tests to pass:

jeweler

mocha

Contributing

If you'd like to contribute to Grit, we ask that you fork mojombo/grit on
GitHub, and push up a topic branch for each feature you add or bug you fix.
Then create an issue and link to the topic branch and explain what the code
does. This allows us to discuss and merge each change separately.

Usage

Grit gives you object model access to your Git repositories. Once you have
created a Repo object, you can traverse it to find parent commits,
trees, blobs, etc.

Initialize a Repo object

The first step is to create a Grit::Repo object to represent your repo. In
this documentation I include the Grit module to reduce typing.

require 'grit'
include Grit
repo = Repo.new("/Users/tom/dev/grit")

In the above example, the directory /Users/tom/dev/grit is my working
directory and contains the .git directory. You can also initialize Grit with
a bare repo.

repo = Repo.new("/var/git/grit.git")

Getting a list of commits

From the Repo object, you can get a list of commits as an array of Commit
objects.

Called without arguments, Repo#commits returns a list of up to ten commits
reachable by the master branch (starting at the latest commit). You can
ask for commits beginning at a different branch, commit, tag, etc.