repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

pi/agent/skills/git/git-sync/SKILL.md

Raw

name: git-sync description: "Synchronize a Git branch by fetching, rebasing onto its target, testing, and optionally pushing when publication was requested. Use for pull, sync, rebase-and-push, or branch publication requests."

Git Sync

Preserve unrelated work, keep history linear, never force-push, and never bypass hooks autonomously.

Resolve context

Procedure

  1. Record the current branch, remote, target, and current commit.
  2. Fetch the resolved remote with pruning and tags.
  3. Count the current commits above the remote target; warn before rebasing more than 50.
  4. Rebase the current branch onto the fetched target.
  5. On conflicts, stop and report the conflicted files, status, and exact continuation or abort choices.
  6. Compare the resulting stack with the recorded stack and report unexpectedly dropped commits.
  7. Run repository-required gates plus requested or obvious fast checks. Stop when a required check fails.
  8. Push only when the user or encompassing request authorized publication. Otherwise stop after local synchronization.
  9. Push the current branch normally. If rejected, fetch, rebase, and test once more, then retry once. If a hook fails, preserve its edits and stop with the failing command and evidence.
  10. Report branch, target, remote, whether a rebase occurred, checks, publication authorization, and any pushed commit.
Markdown source
File outline
---
name: git-sync
description: "Synchronize a Git branch by fetching, rebasing onto its target, testing, and optionally pushing when publication was requested. Use for pull, sync, rebase-and-push, or branch publication requests."
---

# Git Sync

Preserve unrelated work, keep history linear, never force-push, and never bypass hooks autonomously.

## Resolve context

- Require a clean tree, an attached branch, and no merge, rebase, cherry-pick, or revert in progress.
- Resolve the remote from the current branch's configured upstream.
  With no upstream, use the sole configured remote; if several exist, ask.
- Resolve an explicit target first.
  Otherwise use the remote's symbolic HEAD, then the first existing remote branch among `trunk`, `main`, `master`, and `develop`.
  Do not mutate remote configuration merely to discover the target.

## Procedure

1. Record the current branch, remote, target, and current commit.
2. Fetch the resolved remote with pruning and tags.
3. Count the current commits above the remote target; warn before rebasing more than 50.
4. Rebase the current branch onto the fetched target.
5. On conflicts, stop and report the conflicted files, status, and exact continuation or abort choices.
6. Compare the resulting stack with the recorded stack and report unexpectedly dropped commits.
7. Run repository-required gates plus requested or obvious fast checks.
   Stop when a required check fails.
8. Push only when the user or encompassing request authorized publication.
   Otherwise stop after local synchronization.
9. Push the current branch normally.
   If rejected, fetch, rebase, and test once more, then retry once.
   If a hook fails, preserve its edits and stop with the failing command and evidence.
10. Report branch, target, remote, whether a rebase occurred, checks, publication authorization, and any pushed commit.