git-sync
Skill0 starsChanged 17 days agoMITView on GitHub
Synchronize topic branches and align detached HEADs with confirmed git baselines.
- Deletes or force-pushes
- Commits and pushes
7 other projects use a version of this.
Adopted by
Most recently taken up by
- solplum/agent-git-workflow-skillstheir own version, first seen Oct 15, 2026
- EricTechPro/super-boardtheir own version, first seen Oct 3, 2026
- ViktorSoroka07/claude-delivery-skillstheir own version, first seen Sep 28, 2026
- mgiovani/cc-arsenaltheir own version, first seen Sep 25, 2026
- Ldxs001/maby_skillstheir own version, first seen Aug 2, 2026
- ariffazil/arifOStheir own version, first seen May 11, 2026
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 7
- EricTechPro/super-board★ 572same name
- ariffazil/arifOS★ 53same name
- kunwl123456/zeroclaw-skills-collection★ 27same name
- mgiovani/cc-arsenal★ 8same name
- solplum/agent-git-workflow-skills★ 3same name
- Ldxs001/maby_skills★ 0same name
- ViktorSoroka07/claude-delivery-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository12 other files it gives its agents.
- AGENTS.mdAGENTS.md
- buzzer-audio-previewSkill
- cvm-imagegenSkill
- docs-no-revision-markersSkill
- dst-dedicated-serverSkill
- firmware-display-previewSkill
- git-remote-troubleshootSkill
- linux-server-initSkill
- markdown-doc-styleSkill
- step-stl-print-repairSkill
- tavily-hikari-infraSkill
- xp-infraSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
17 rules. 0 are common, 11 are distinctive, and 6 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
11
Distinctive
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 8
Use this skill for pure local git synchronization: fetching remotes, aligning a detached HEAD to a confirmed base, fast-forwarding a topic …
- Distinctive: line 34
Always fetch before comparing against remote refs.
- Distinctive: line 35
Never change remote URLs, push URLs, credential helpers, upstreams, or transport settings.
- Distinctive: line 36
Never push unless the owner or outer flow explicitly authorizes that exact remote update.
- Very specific: line 41
If the owner or active flow forbids history rewrite or force-push, stop rebase-base instead of switching to a different strategy.
- Very specific: line 58
use provided REMOTE when present.
- Distinctive: line 72
use a probed candidate only when exactly one exists.
- Distinctive: line 73
if multiple plausible targets remain or none exists, ask which branch the PR/work should target.
- Distinctive: line 75
Only treat the resolved base as confirmed when it came from an explicit input, a remote default branch, or a single unambiguous common …
- Very specific: line 81
If REMOTE is unknown and BASE_REF is remote-qualified, derive the remote from BASE_REF.
- Distinctive: line 91
Use this only when the upstream has been verified to represent the same topic branch head.
- Distinctive: line 95
If fast-forward is impossible, stop and report the non-ff state.
- Distinctive: line 101
If dirty, preserve local changes with:
- Distinctive: line 107
If a stash was created, replay with git stash apply.
- Distinctive: line 108
If the branch is published, report that remote update requires git push --force-with-lease.
- Very specific: line 112
Use this only for ACTION=align-detached-base, or for an owner bare mainline-sync request that resolved this action because the current HEAD …
- Very specific: line 126
Verify that HEAD is still detached, the worktree is clean, and record ahead/behind after the move.
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Git sync
Use this skill for pure local git synchronization: fetching remotes, aligning a detached HEAD to a confirmed base, fast-forwarding a topic branch to its verified upstream, rebasing a topic branch onto a confirmed base, and checking ahead/behind state.
This skill does not create PRs, merge PRs, clean worktrees, or change remote configuration. PR freshness and GitHub merge behavior remain owned by $project-engineering-workflow.
Prerequisites and validation boundary
This is a text workflow using the operator's installed Git and configured remotes on Linux/macOS; it has no production script or programming-runtime requirement. Use ACTION=check BASE_REF=origin/main REMOTE=origin for a read-only divergence request after the documented fetch. Results are the branch/detached identity, confirmed base and ahead/behind counts described below. Fetch updates remote-tracking refs; alignment/rebase/fast-forward mutate local Git state only under the chosen action's authorization.
The owned behavior suite uses installed Bun and Git: bun test ./tests/detached_alignment_contract.test.ts from this Skill. It creates temporary local repositories and a filesystem bare remote, then checks actual refs, HEAD, reflog recoverability, configuration invariance and blocked actions. This is isolated native Git evidence, not external remote access. The Bun command implementation is test-only; it adds no production Git CLI and does not replace the workflow instructions.
Inputs
ACTION=fetch|check|align-detached-base|ff-topic-upstream|rebase-base; default selection is described below.BASE_REF: confirmed target base ref, for exampleorigin/main.REMOTE: remote to fetch. Required whenBASE_REFpoints to a remote; otherwise default tooriginwhen that remote exists, or the sole configured remote when exactly one remote exists.ALLOW_REBASE: explicit outer-flow authorization for history rewrite. Optional for the default Step 4 confirmed-base contract where the caller passes onlyBASE_REFandREMOTE.ALLOW_FORCE_WITH_LEASE: explicit outer-flow authorization for updating a published branch after rebase.
When a caller passes only BASE_REF and REMOTE, use the confirmed-base sync contract: fetch the remote, check divergence, and rebase the current topic branch onto the confirmed base. Treat that exact bare call shape as the active shared linear-history sync authorization. In $project-engineering-workflow, this same confirmed-base path may run once in Step 1 as a topic-branch freshness pre-sync and again in Step 4 as the canonical closeout recheck. Do not infer a different sync strategy from vague wording.
When the owner makes a bare mainline-sync request without BASE_REF / REMOTE, resolve a reliable default base locally instead of asking immediately. If HEAD is detached, select align-detached-base; otherwise preserve the old rebase-base behavior. Ask only when the base ref is ambiguous, no suitable remote/base exists, or the selected operation is blocked by its guardrails.
ACTION=align-detached-base is also available for an explicit owner request to align the current detached worktree to a confirmed BASE_REF. It is a direct checkout operation, not a rebase. An explicit ACTION always wins; the exact BASE_REF + REMOTE caller shape above remains rebase-base even when the caller happens to be detached.
Guardrails
- Always fetch before comparing against remote refs.
- Never change remote URLs, push URLs, credential helpers, upstreams, or transport settings.
- Never push unless the owner or outer flow explicitly authorizes that exact remote update.
- Never run
reset --hard. - Rebase requires a safety backup ref.
align-detached-baserequires a detachedHEAD, a clean worktree, a confirmed base, and a recoverable old commit. Do not stash changes, create a branch or backup ref, or turn the worktree into a branch.- Detached
HEADis allowed forACTION=fetch|check|align-detached-base; stop beforeff-topic-upstreamorrebase-base. - If the owner or active flow forbids history rewrite or force-push, stop
rebase-baseinstead of switching to a different strategy. This does not prohibit an explicitly selected direct detached alignment because it does not rewrite history.
Workflow
1) Preflight
git rev-parse --show-toplevelgit rev-parse --abbrev-ref HEADgit status --porcelain
For ACTION=align-detached-base, require a detached HEAD and an empty git status --porcelain; otherwise stop before fetch, checkout, or any preservation action. For ff-topic-upstream and rebase-base, a detached HEAD remains a blocker. When an owner bare mainline-sync request omits ACTION, choose align-detached-base only after confirming that HEAD is detached; the BASE_REF + REMOTE caller shape remains rebase-base.
2) Resolve remote and base
For bare "sync mainline" requests:
- Resolve
REMOTE:- use provided
REMOTEwhen present; - otherwise use
originwhen it exists; - otherwise use the sole configured remote when exactly one remote exists;
- otherwise ask one key question.
- use provided
- Fetch before resolving remote-tracking refs:
git fetch --prune <REMOTE>
- Resolve
BASE_REF:- use provided
BASE_REFwhen present; - otherwise use the remote default branch when it resolves:
git symbolic-ref --quiet --short refs/remotes/<REMOTE>/HEAD
- otherwise probe common candidates:
<REMOTE>/main<REMOTE>/master<REMOTE>/develop
- use a probed candidate only when exactly one exists.
- if multiple plausible targets remain or none exists, ask which branch the PR/work should target.
- use provided
Only treat the resolved base as confirmed when it came from an explicit input, a remote default branch, or a single unambiguous common candidate.
3) Fetch
git fetch --prune <REMOTE>
If REMOTE is unknown and BASE_REF is remote-qualified, derive the remote from BASE_REF. Otherwise use the remote/base resolution step above.
4) Check divergence
git rev-list --left-right --count HEAD...<BASE_REF>
Left count is local-only commits. Right count is base-only commits.
5) Fast-forward to topic upstream
Use this only when the upstream has been verified to represent the same topic branch head.
git pull --ff-only
If fast-forward is impossible, stop and report the non-ff state.
6) Rebase onto confirmed base
Use this when ACTION=rebase-base, when the owner made a bare mainline-sync request, the base was resolved unambiguously, and HEAD is attached to a topic branch, or when ACTION is omitted and both BASE_REF and REMOTE are provided by a caller that already resolved the confirmed base. Rebase is authorized by ALLOW_REBASE=yes, by an active flow that grants linear-history sync, by an unambiguous bare mainline-sync request on an attached topic branch, or by the exact default Step 4 call shape that provides only BASE_REF and REMOTE.
- If dirty, preserve local changes with:
git stash push -u -m "wip: before git-sync rebase"
- Create backup:
git branch "backup/<branch>-before-git-sync-<timestamp>"
- Rebase:
git rebase <BASE_REF>
- If a stash was created, replay with
git stash apply; drop it only after a clean replay. - If the branch is published, report that remote update requires
git push --force-with-lease; run it only with explicit authorization.
7) Align detached HEAD to confirmed base
Use this only for ACTION=align-detached-base, or for an owner bare mainline-sync request that resolved this action because the current HEAD is detached. It must not be used as a fallback for blocked rebase or fast-forward requests.
- Confirm again that
git rev-parse --abbrev-ref HEADprintsHEADandgit status --porcelainis empty. - Fetch and resolve the confirmed base as above, then capture exact commits:
OLD_HEAD=$(git rev-parse HEAD)TARGET_SHA=$(git rev-parse --verify "<BASE_REF>^{commit}")
- Prove that
OLD_HEADwill remain recoverable. It is sufficient for the target commit or an existing ref to contain it; otherwise the existing HEAD reflog must containOLD_HEAD. If none of these conditions holds, stop before switching because the owner did not authorize a backup ref.git merge-base --is-ancestor "$OLD_HEAD" "$TARGET_SHA"git for-each-ref --contains="$OLD_HEAD" --format='%(refname)' refs/heads refs/remotes refs/tagsgit reflog exists HEAD && git reflog show --format='%H' HEAD | grep -Fx "$OLD_HEAD"
- Record ahead/behind before the move:
git rev-list --left-right --count "$OLD_HEAD...$TARGET_SHA"
- Align without creating a branch:
git switch --detach "$TARGET_SHA"
- Verify that
HEADis still detached, the worktree is clean, and record ahead/behind after the move. Report whether the recovery path was target ancestry, an existing ref, or the HEAD reflog.
Output
Report:
- branch, or
HEAD (detached)for direct alignment - base ref and remote
- ahead/behind before and after
- old and new
HEADplus the recovery path for direct alignment; backup ref when a rebase created one - whether a push is needed and whether it was authorized
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

