Skip to main content

Module git

Module git 

Source

Enums§

HookInstallResult
Result of installing hook lines into a file.

Functions§

checkout_branch
Switch back to a branch.
commit_files
Stage specific files and commit. Retries once on commit failure to handle pre-commit hooks that auto-fix files (e.g., end-of-file-fixer, trailing-whitespace) — these hooks modify files and return exit code 1, expecting a re-stage + re-commit.
create_branch
Create and checkout a new git branch from a specific start point. Use start_point like "origin/main" to branch from the remote default branch.
create_pr
Create a PR using gh pr create. Returns the PR URL on success. base specifies the target branch for the PR (e.g., “main”).
create_retro_pr
Create a retro PR: chdir → stash → branch from default → write files → commit → push → PR → restore. Returns the PR URL on success, or None if PR creation was skipped.
current_branch
Get the current git branch name.
default_branch
Detect the repository’s default branch name via gh.
fetch_branch
Fetch a specific branch from origin.
git_root
Get the git repository root directory.
install_hooks
Install retro git hooks (post-commit only) into the repository. Also cleans up old post-merge hooks that were retro-managed.
is_gh_available
Check if the gh CLI is available on PATH.
is_in_git_repo
Check if we are inside a git repository.
pr_state
Check the state of a PR by its URL. Returns “OPEN”, “CLOSED”, or “MERGED”.
push_current_branch
Push the current branch to origin.
remove_hooks
Remove retro hook lines from git hooks in the given repository. Returns the list of hooks that were modified.
stash_pop
Pop the most recent stash entry.
stash_push
Stash uncommitted changes. Returns true if something was stashed.