pygit2

Python bindings for libgit2.

class pygit2.Blob

Bases: pygit2.Object

Blob objects

data

raw data

class pygit2.Commit

Bases: pygit2.Object

Commit objects

author

author

commit_time

commit time

commit_time_offset

commit time offset

committer

committer

message

message

message_encoding

message encoding

parents

parents of this commit

tree

tree object

class pygit2.Index

Bases: object

Index file

add()

Add or update an index entry from a file in disk.

clear()

Clear the contents (all the entries) of an index object.

read()

Update the contents of an existing index object in memory by reading from the hard disk.

read_tree()

Update the index file from the given tree object.

write()

Write an existing index object from memory back to disk using an atomic file lock.

write_tree()

Create a tree object from the index file, return its oid.

class pygit2.IndexEntry

Bases: object

Index entry

hex

hex oid

mode

mode

oid

object id

path

path

class pygit2.Object

Bases: object

Object objects

hex

hex oid

oid

object id

read_raw()

Read the raw contents of the object from the repo.

type

type number

class pygit2.Reference

Bases: object

Reference

delete()

Delete this reference. It will no longer be valid!

hex

hex oid

name

The full name of a reference.

oid

object id

reload()

Reload the reference from the file-system.

rename()

Rename the reference.

resolve()

Resolve a symbolic reference and return a direct reference.

target

target

type

type (GIT_REF_OID, GIT_REF_SYMBOLIC or GIT_REF_PACKED).

class pygit2.Repository

Bases: object

Git repository

TreeBuilder()

Create a TreeBuilder object for this repository.

create_blob()

Create a new blob from memory

create_commit()

Create a new commit object, return its SHA.

create_reference()

Create a new reference “name” that points to the object given by its “sha”.

create_symbolic_reference()

Create a new symbolic reference “name” that points to the reference “target”.

create_tag()

Create a new tag object, return its SHA.

index

index file.

listall_references()

Return a list with all the references in the repository.

lookup_reference()

Lookup a reference by its name in a repository.

packall_references()

Pack all the loose references in the repository.

path

The normalized path to the git repository.

read()

Read raw object data from the repository.

status()

Reads the status of the repository and returns a dictionary with file paths as keys and status flags as values. See pygit2.GIT_STATUS_*.

status_file()

Returns the status of the given file path.

walk()

Generator that traverses the history starting from the given commit.

workdir

The normalized path to the working directory of the repository. If the repository is bare, None will be returned.

write()

Write raw object data into the repository. First arg is the object type, the second one a buffer with data. Return the object id (sha) of the created object.

class pygit2.Signature

Bases: object

Signature

email

Email

name

Name

offset

Offset

time

Time

class pygit2.Tag

Bases: pygit2.Object

Tag objects

message

tag message

name

tag name

tagger

tagger

target

tagged object

class pygit2.Tree

Bases: pygit2.Object

Tree objects

class pygit2.TreeEntry

Bases: object

TreeEntry objects

attributes

attributes

hex

hex oid

name

name

oid

object id

to_object()

Look up the corresponding object in the repo.

pygit2.discover_repository()

Look for a git repository and return its path.

pygit2.init_repository()

Creates a new Git repository in the given folder.

Previous topic

Welcome to pygit2’s documentation!

This Page