Git Operations

Manage git repositories and configuration.

git.config

Manage git config for a repository or globally.

git.config(key, value, repo=None)
  • key: the key of the config to ensure
  • value: the value this key should have
  • repo: specify the git repo path to edit local config (defaults to global)

Example:

git.config(
    name='Ensure user name is set for a repo',
    key='user.name',
    value='Anon E. Mouse',
    repo='/usr/local/src/pyinfra',
)

git.repo

Clone/pull git repositories.

git.repo(
    src, dest, branch='master', pull=True, rebase=False, user=None, group=None,
    ssh_keyscan=False, update_submodules=False, recursive_submodules=False,
)
  • src: the git source URL
  • dest: directory to clone to
  • branch: branch to pull/checkout
  • pull: pull any changes for the branch
  • rebase: when pulling, use --rebase
  • user: chown files to this user after
  • group: chown files to this group after
  • ssh_keyscan: keyscan the remote host if not in known_hosts before clone/pull
  • update_submodules: update any git submodules
  • recursive_submodules: update git submodules recursively

Example:

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