Skip to main content
The git module is a lightweight wrapper around common git operations. For more complex operations, you can execute commands directly using the bash utility. Credentials are automatically configured by default. Default configuration:

Example Usage

Methods

add

Stages a file or files for commit. If all is True, stages all changes.
string
File path to add (ignored if all=True).
bool
If True, adds all changes instead of a single file.

branch

Creates a new branch by default. If checkout is True, creates and checks out (git checkout -b branch-name), otherwise just creates a branch with branch-name.
string
The name of the new branch.
bool
Whether to create and checkout the branch.

checkout

Clones a repository into target_dir. If ref is provided, it checks out that specific branch/tag.
string
The local directory for the clone.
string
The Git ref (branch, tag) to clone. Defaults to "" (clone the default branch).
bool
If True, this indicates the intention to create a new branch, but is not currently used in the command.

clone

An alias for checkout, providing the same behavior for consistency.
string
The local directory for the clone.
string
The Git ref (branch, tag) to clone. Defaults to "" (clone the default branch).
bool
If True, this indicates the intention to create a new branch, but is not currently used in the command.

commit

Commits staged changes with a given commit message.
string
The commit message.

init

Initializes a new Git repository locally.

pull

Pulls from the repository specified by the class’s constructed remote URL. It runs git pull origin=url HEAD.

push

Pushes the current HEAD to the remote. If publish is True, it pushes with the -u origin HEAD flag, setting the upstream branch.
bool
Whether to set upstream on push.