Skip to main content

Module git_util

Module git_util 

Source

Enums§

BranchClass
Classification of a local branch relative to its origin counterpart.
MidMergeState
Describes which incomplete git operation is in progress. Presence of the corresponding marker file/directory under .git/ is definitive — git creates these for the duration of the operation and removes them on commit or abort.

Functions§

branch_tip
Get the commit SHA at the tip of a local branch.
classify_branch
Classify local branch relative to remote ref using SHA equality and directed ancestry.
commit
commit_files_to_branch
Commit multiple files to a branch in a single commit without disturbing the working tree.
commit_to_branch
Commit a file to a specific branch without disturbing the current working tree.
create_branch_at
Create a local branch pointing at a specific commit SHA.
current_branch
delete_local_branch
delete_remote_branch
Delete a remote branch on origin.
detect_mid_merge_state
Detect whether the repo is in a mid-merge, mid-rebase, or mid-cherry-pick state.
fetch_all
fetch_branch
git_config_get
has_commits
has_remote
is_ancestor
Check if commit is a git ancestor of of_ref (i.e. reachable from of_ref). Uses git merge-base --is-ancestor.
is_file_tracked
is_worktree_dirty
list_files_on_branch
List all files in a directory on a branch (non-recursive).
local_branch_exists
main_worktree_root
merge_base
Run git merge-base ref1 ref2 and return the common ancestor SHA.
merge_branch_into_default
merge_into_default
merge_ref
merged_into_main
ticket/* branches that are merged into the default branch (remote or local), including branches that were squash-merged (not detected by --merged).
move_files_on_branch
Move files on a branch in a single commit. Each element of moves is (old_rel_path, new_rel_path, content). Writes each new file, stages it, then removes each old file via git rm. Uses the same permanent-worktree / temp-worktree pattern as commit_files_to_branch.
prune_remote_tracking
pull_default
push_branch
push_branch_tracking
push_ticket_branches
Push all local ticket/* branches that have commits not yet on origin. Non-fatal: logs warnings on push failure. No-op when no origin is configured.
read_from_branch
Read a file’s content from a branch ref without changing working tree. Prefers the local ref (reflects recent commits before push); falls back to origin when no local ref exists.
remote_branch_tip
Get the commit SHA at the tip of the remote tracking ref for a branch.
remote_ticket_branches_with_dates
Merge branch into default_branch (fast-forward or merge commit). Pushes default_branch to origin when a remote exists. List remote ticket/* branches with their last commit date. Returns (branch_name_without_origin_prefix, commit_date) pairs.
resolve_branch_sha
Resolve a branch name to a commit SHA. Prefers origin/<branch>; falls back to local <branch>.
stage_files
sync_default_branch
Bring local default branch into sync with origin/<default> without ever pushing.
sync_non_checked_out_refs
Sync non-checked-out ticket/* and epic/* local refs with their origin counterparts.
ticket_branches
All ticket/* branch names visible locally or remotely (deduplicated). Local branches are included even when a remote exists, so that unpushed branches (e.g. just created) are visible without a push.