Skip to main content

Module pull_rebase

Module pull_rebase 

Source
Expand description

pre-push-pull-rebase — sync a branch with ITS OWN upstream before pushing, and warn (never act) when the default branch has moved ahead.

The hardening in the shell version is the point, and is preserved exactly: an older version ran git pull --rebase origin HEAD, where the remote ref HEAD resolves to the remote’s DEFAULT branch — so every push silently rebased onto main, autostashing uncommitted work. Hence: never touch a dirty tree, rebase only onto the branch’s own upstream, and abort cleanly on conflict rather than leaving a half-rebased state.

Functions§

ahead_count
Left side of git rev-list --left-right --count <a>...<b>: how far the default branch is ahead of us.
behind_count
behind[[:space:]]+N over git status -sb, present or not — UNLIKE divergence, which only answers when ahead is ALSO on the line.
divergence
lists_branch
^[[:space:]*+]+<name>$ over git branch output — the indentation git always prints, plus the markers it puts in column 0.
run