Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/pyinfra-dev/pyinfra/llms.txt

Use this file to discover all available pages before exploring further.

Manage git repositories and configuration.

Functions

git.config

Manage git config at repository, user or system level.
git.config(
    key,
    value,
    multi_value=False,
    repo=None,
    system=False,
)

git.repo

Clone/pull git repositories.
git.repo(
    src,
    dest,
    branch=None,
    pull=True,
    rebase=False,
    user=None,
    group=None,
    ssh_keyscan=False,
    update_submodules=False,
    recursive_submodules=False,
)

git.worktree

Manage git worktrees.
git.worktree(
    worktree,
    repo=None,
    detached=False,
    new_branch=None,
    commitish=None,
    pull=True,
    rebase=False,
    from_remote_branch=None,
    present=True,
    force=False,
    user=None,
    group=None,
)

git.bare_repo

Create bare git repositories.
git.bare_repo(
    path,
    user=None,
    group=None,
    present=True,
)

Examples

from pyinfra.operations import git

# Clone a repository
git.repo(
    name="Clone repo",
    src="https://github.com/Fizzadar/pyinfra.git",
    dest="/usr/local/src/pyinfra",
)

# Set git config
git.config(
    name="Always prune specified repo",
    key="fetch.prune",
    value="true",
    repo="/usr/local/src/pyinfra",
)

# Create a bare repository
git.bare_repo(
    name="Create bare repo",
    path="/home/git/test.git",
)

Build docs developers (and LLMs) love