From ac-git
Finds true Git branch fork point despite rebases/squashes, detects unknown parents via commit counts, history rewrites via reflog, and squashed branches.
npx claudepluginhub waterplanai/agentic-config --plugin ac-gitThis skill is limited to using the following tools:
Determines the true fork point of a branch, accounting for rebases, squashes, and unknown parent branches.
Generates partial rebase plan table and git rebase --onto command for squash-merge repos by auto-detecting commits to keep or drop.
Manages Git forked repositories: sets up origin/upstream remotes, detects divergence with rev-list/log, syncs branches, and advises sync strategies/contribution prep.
Lists local and remote git branches for cleanup: merged into base (main/master) or inactive beyond configurable threshold (default 3 months).
Share bugs, ideas, or general feedback.
Determines the true fork point of a branch, accounting for rebases, squashes, and unknown parent branches.
BRANCH=$(git rev-parse --abbrev-ref HEAD)
HEAD_SHA=$(git rev-parse --short HEAD)
When parent is unknown, find closest by commit count:
git branch -a --format='%(refname:short)' | while read b; do
[[ "$b" == "$BRANCH" ]] && continue
base=$(git merge-base "$b" HEAD 2>/dev/null) || continue
count=$(git rev-list --count "$base..HEAD")
echo "$count $base $b"
done | sort -n | head -5
Lowest count = closest parent.
PARENT="main" # or detected from Step 2
MERGE_BASE=$(git merge-base "$PARENT" HEAD)
REFLOG_ORIGIN=$(git reflog show "$BRANCH" --format='%H %gs' | grep 'branch: Created' | awk '{print $1}')
if [[ "$REFLOG_ORIGIN" != "$MERGE_BASE" ]]; then
echo "HISTORY REWRITTEN"
# Check if reflog commit still ancestor
git merge-base --is-ancestor "$REFLOG_ORIGIN" HEAD 2>/dev/null && echo "Partial rebase" || echo "Full rebase/squash"
fi
COMMIT_COUNT=$(git rev-list --count "$MERGE_BASE..HEAD")
[[ "$COMMIT_COUNT" -eq 1 ]] && echo "Branch appears SQUASHED"
# Tags pointing to orphaned commits
for tag in $(git tag); do
tag_sha=$(git rev-parse "$tag" 2>/dev/null)
git merge-base --is-ancestor "$tag_sha" HEAD 2>/dev/null || echo "Orphaned: $tag -> $tag_sha"
done
| Field | Value |
|---|---|
| Branch | {branch_name} |
| HEAD | {sha} |
| Parent Branch | {parent} |
| Merge-Base | {sha} - "{commit message}" |
| Commits Since Fork | {count} |
| History Rewritten | Yes/No |
| Squashed | Yes/No |
git merge-base gives the fork point for CURRENT history state. Original fork point after rebase/squash must be recovered from reflog, tags, or dangling objects (none guaranteed to exist).