Files
deb-python-pygit2/docs/repository.rst
J. David Ibáñez 611e979113 Now Repository.head returns a reference (#203)
Now Repository.head behaves like libgit2's git_repository_head, it
returns the resolved reference. These two lines are equivalent:

  ref = repo.head
  ref = repo.lookup_reference('HEAD').resolve()

Before it returned a commit.
2013-04-17 08:16:43 +02:00

1.1 KiB

The repository

Everything starts either by creating a new repository, or by opening an existing one.

Creating a repository

pygit2.init_repository

This is how to create non-bare repository:

>>> from pygit2 import init_repository
>>> repo = init_repository('test')

And this is how to create a bare repository:

>>> from pygit2 import init_repository
>>> repo = init_repository('test', bare=True)

But one can also do:

>>> from pygit2 import init_repository
>>> repo = init_repository('test', True)

The Repository class

To open an existing repository:

>>> from pygit2 import Repository
>>> repo = Repository('pygit2/.git')

pygit2.Repository.path

pygit2.Repository.workdir

pygit2.Repository.is_bare

pygit2.Repository.is_empty

pygit2.Repository.read

pygit2.Repository.write