Files
deb-python-pygit2/docs/repository.rst
J. David Ibáñez 718a2df1d5 Fix building the docs
2015-02-07 08:37:41 +01:00

2.2 KiB

The repository

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

Contents

Functions

pygit2.init_repository

Example:

>>> from pygit2 import init_repository
>>> repo = init_repository('test')            # Creates a non-bare repository
>>> repo = init_repository('test', bare=True) # Creates a bare repository

pygit2.clone_repository

Example:

>>> from pygit2 import clone_repository
>>> repo_url = 'git://github.com/libgit2/pygit2.git'
>>> repo_path = '/path/to/create/repository'
>>> repo = clone_repository(repo_url, repo_path) # Clones a non-bare repository
>>> repo = clone_repository(repo_url, repo_path, bare=True) # Clones a bare repository

pygit2.discover_repository

Example:

>>> current_working_directory = os.getcwd()
>>> repository_path = discover_repository(current_working_directory)
>>> repo = Repository(repository_path)

The Repository class

The Repository constructor only takes one argument, the path of the repository to open.

Example:

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

The API of the Repository class is quite large. Since this documentation is orgaized by features, the related bits are explained in the related chapters, for instance the pygit2.Repository.checkout method are explained in the Checkout section.

Below there are some general attributes and methods:

pygit2.Repository.path

pygit2.Repository.workdir

pygit2.Repository.is_bare

pygit2.Repository.is_empty

pygit2.Repository.default_signature

pygit2.Repository.read

pygit2.Repository.write

pygit2.Repository.reset

pygit2.Repository.state_cleanup

pygit2.Repository.write_archive

pygit2.Repository.ahead_behind