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:]]+Novergit status -sb, present or not — UNLIKEdivergence, which only answers whenaheadis ALSO on the line.- divergence
- lists_
branch ^[[:space:]*+]+<name>$overgit branchoutput — the indentation git always prints, plus the markers it puts in column 0.- run