class documentation

A git repository backed by local disk.

To open an existing repository, call the constructor with the path of the repository.

To create a new repository, use the Repo.init class method.

Note that a repository object may hold on to resources such as file handles for performance reasons; call .close() to free up those resources.

Class Method discover Iterate parent directories to discover a repository
Class Method init Create a new repository.
Class Method init_bare Create a new bare repository.
Method __enter__ Undocumented
Method __exit__ Undocumented
Method __init__ Open a repository.
Method __repr__ Undocumented
Method clone Clone this repository.
Method close Close any files opened by this repository.
Method commondir Return the path of the common directory.
Method controldir Return the path of the control directory.
Method get_blob_normalizer Return a BlobNormalizer object
Method get_config Retrieve the config object.
Method get_description Retrieve the description of this repository.
Method get_named_file Get a file from the control dir with a specific name.
Method has_index Check if an index is present.
Method index_path Return path to the index file.
Method open_index Open the index for this repository.
Method reset_index Reset the index back to a specific tree.
Method set_description Set the description for this repository.
Method stage Stage a set of paths.
Method unstage unstage specific file in the index
Instance Variable bare Whether this is a bare repository
Instance Variable path Path to the working copy (if it exists) or repository control directory (if the repository is bare)
Instance Variable symlink_fn Undocumented
Class Method _init_maybe_bare Undocumented
Class Method _init_new_working_directory Create a new working directory linked to a repository.
Method _del_named_file Delete a file in the control directory with the given name.
Method _determine_file_mode Probe the file-system to determine whether permissions can be trusted.
Method _put_named_file Write a file to the control dir with the given name and contents.
Method _write_reflog Undocumented
Instance Variable _commondir Undocumented
Instance Variable _controldir Undocumented
Instance Variable _graftpoints Undocumented

Inherited from BaseRepo:

Method __contains__ Check if a specific Git object or ref is present.
Method __delitem__ Remove a ref.
Method __getitem__ Retrieve a Git object by SHA1 or ref.
Method __setitem__ Set a ref.
Method do_commit Create a new commit.
Method fetch Fetch objects into another repository.
Method fetch_objects Fetch the missing objects required for a set of revisions.
Method fetch_pack_data Fetch the pack data required for a set of revisions.
Method generate_pack_data Generate pack data objects for a set of wants/haves.
Method get_config_stack Return a config stack for this repository.
Method get_graph_walker Retrieve a graph walker.
Method get_object Retrieve the object with the specified SHA.
Method get_parents Retrieve the parents of a specific commit.
Method get_peeled Get the peeled value of a ref.
Method get_refs Get dictionary with all refs.
Method get_shallow Get the set of shallow commits.
Method get_walker Obtain a walker for this repository.
Method head Return the SHA1 pointed at by HEAD.
Method parents_provider Undocumented
Method update_shallow Update the list of shallow objects.
Instance Variable hooks Undocumented
Instance Variable object_store Dictionary-like object for accessing the objects
Instance Variable refs Dictionary-like object with the refs in this repository
Method _add_graftpoints Add or modify graftpoints
Method _get_object Undocumented
Method _get_user_identity Determine the identity to use for new commits.
Method _init_files Initialize a default set of named files.
Method _read_heads Undocumented
Method _remove_graftpoints Remove graftpoints
@classmethod
def discover(cls, start='.'):

Iterate parent directories to discover a repository

Return a Repo object for the first parent directory that looks like a Git repository.

Parameters
startThe directory to start discovery from (defaults to '.')
@classmethod
def init(cls, path, mkdir=False):

Create a new repository.

Returns: Repo instance

Parameters
path:strPath in which to create the repository
mkdir:boolWhether to create the directory
Returns
RepoUndocumented
@classmethod
def init_bare(cls, path, mkdir=False, object_store=None):

Create a new bare repository.

path should already exist and be an empty directory.

Returns: a Repo instance

Parameters
pathPath to create bare repository in
mkdirUndocumented
object_storeUndocumented
def __enter__(self):

Undocumented

def __exit__(self, exc_type, exc_val, exc_tb):

Undocumented

def __init__(self, root, object_store=None, bare=None):

Open a repository.

This shouldn't be called directly, but rather through one of the base classes, such as MemoryRepo or Repo.

Parameters
root:strUndocumented
object_store:Optional[BaseObjectStore]Object store to use
bare:Optional[bool]Undocumented
refsRefs container to use
def __repr__(self):

Undocumented

def clone(self, target_path, mkdir=True, bare=False, origin=b'origin', checkout=None, branch=None, progress=None, depth=None):

Clone this repository.

Returns: Created repository as Repo

Parameters
target_pathTarget path
mkdirCreate the target directory
bareWhether to create a bare repository
originBase name for refs in target repository cloned from this repository
checkoutWhether or not to check-out HEAD after cloning
branchOptional branch or tag to be used as HEAD in the new repository instead of this repository's HEAD.
progressOptional progress function
depthDepth at which to fetch
def close(self):

Close any files opened by this repository.

def commondir(self):

Return the path of the common directory.

For a main working tree, it is identical to controldir().

For a linked working tree, it is the control directory of the main working tree.

def controldir(self):

Return the path of the control directory.

def get_blob_normalizer(self):

Return a BlobNormalizer object

def get_config(self):

Retrieve the config object.

Returns: ConfigFile object for the .git/config file.

Returns
ConfigFileUndocumented
def get_description(self):

Retrieve the description of this repository.

Returns: A string describing the repository or None.

def get_named_file(self, path, basedir=None):

Get a file from the control dir with a specific name.

Although the filename should be interpreted as a filename relative to the control dir in a disk-based Repo, the object returned need not be pointing to a file in that location.

Returns: An open file object, or None if the file does not exist.

Parameters
pathThe path to the file, relative to the control dir.
basedirOptional argument that specifies an alternative to the control dir.
def has_index(self):

Check if an index is present.

def index_path(self):

Return path to the index file.

def open_index(self):

Open the index for this repository.

Returns: The matching Index

Returns
IndexUndocumented
Raises
NoIndexPresentIf no index is present
def reset_index(self, tree=None):

Reset the index back to a specific tree.

Parameters
tree:Optional[bytes]Tree SHA to reset to, None for current HEAD tree.
def set_description(self, description):

Set the description for this repository.

Parameters
descriptionText to set as description for this repository.
def stage(self, fs_paths):

Stage a set of paths.

Parameters
fs_paths:Union[str, bytes, os.PathLike, Iterable[Union[str, bytes, os.PathLike]]]List of paths, relative to the repository path
def unstage(self, fs_paths):

unstage specific file in the index

Parameters
fs_paths:List[str]a list of files to unstage, relative to the repository path
bare =

Whether this is a bare repository

path =

Path to the working copy (if it exists) or repository control directory (if the repository is bare)

symlink_fn =

Undocumented

@classmethod
def _init_maybe_bare(cls, path, controldir, bare, object_store=None):

Undocumented

@classmethod
def _init_new_working_directory(cls, path, main_repo, identifier=None, mkdir=False):

Create a new working directory linked to a repository.

Returns: Repo instance

Parameters
pathPath in which to create the working tree.
main_repoMain repository to reference
identifierWorktree identifier
mkdirWhether to create the directory
def _del_named_file(self, path):

Delete a file in the control directory with the given name.

def _determine_file_mode(self):

Probe the file-system to determine whether permissions can be trusted.

Returns: True if permissions can be trusted, False otherwise.

def _put_named_file(self, path, contents):

Write a file to the control dir with the given name and contents.

Parameters
pathThe path to the file, relative to the control dir.
contentsA string to write to the file.
def _write_reflog(self, ref, old_sha, new_sha, committer, timestamp, timezone, message):

Undocumented

_commondir =

Undocumented

_controldir =

Undocumented

_graftpoints: dict =

Undocumented