git-branch-sync
Skill6 starsChanged 44 days agoMITView on GitHub
Fetch the latest base branch and rebase the current branch onto it, surfacing conflicts clearly. Use when the user asks to sync, rebase, update from main, pull latest changes, or /git-branch-sync. Also trigger on "catch up with main", "rebase onto main", "update my branch", or whenever the user signals their branch is stale vs base. Runs immediately without asking for confirmation.
- Deletes or force-pushes
- Commits and pushes
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 4 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
4
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 25
No remote -> skip the fetch, git rebase <base> (local ref).
- Distinctive: line 28
Stop + surface. No auto-resolve
- Distinctive: line 30
Leave stash in place. Tell user to pop after resolve
- Very specific: line 37
Always rebase, never merge.
- Distinctive: line 38
Never force-push here. Pushed branch rebased -> tell user git push --force-with-lease.
- Distinctive: line 39
Never git rebase --skip / drop commits to "make it work".
- Very specific: line 40
Never --no-verify. Why -> hooks gate broken state.
- Very specific: line 41
No upstream -> sync vs origin/<base>.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Git Branch Sync
Catch current branch up to base. Rebase only. Surface conflicts.
Flow
- Parallel:
git status --porcelaingit branch --show-currentgit rev-parse --abbrev-ref --symbolic-full-name @{u}(upstream if any)- Rebase/merge already in progress (
git statussays so) or detached HEAD (git branch --show-currentempty) -> stop with a one-line explanation. Why -> a secondgit rebaseon top of a half-finished one errors confusingly, and there is no current branch to sync
- Base: user names one -> verbatim. Else detect:
git symbolic-ref --short refs/remotes/origin/HEAD-> strip theorigin/; ref missing ->git remote set-head origin -a, re-read; no remote ->main, fall backmaster. Why -> rebasing ontomainin adevelop-based repo replays the branch onto the wrong parent and manufactures conflicts that aren't real - Dirty -> stash:
git stash push -u -m "sync-branch auto-stash". Pop later. Unsafe (unresolved merge) -> stop + tell user - On base ->
git pull --ff-only origin <base>. Fails (local base diverged) -> pop the stash if step 3 made one (nothing was rewritten), then stop + tell user. No auto-rebase of base itself - Else:
git fetch origin <base>git rebase origin/<base>- No remote -> skip the fetch,
git rebase <base>(local ref). Local<base>absent too -> nothing to sync against; pop the stash if step 3 made one, stop + say so
- Conflicts:
git status-> list conflicted paths- Stop + surface. No auto-resolve
- Tell user: resolve,
git add <paths>,git rebase --continue. Mentiongit rebase --abortescape - Leave stash in place. Tell user to pop after resolve
- Rebase done (clean or aborted) -> pop stash if created
- Print one-liner: branch, base, commits replayed (
git rev-list --count origin/<base>..HEADbefore the rebase vs after), force-push needed? (yes = upstream exists and history was rewritten)- 0 commits replayed (already up to date) -> say so explicitly; don't mention force-push (nothing rewritten)
Rules
- Always rebase, never merge. Why -> user workflow preference; linear history. Don't offer merge as alternative even on shared branches; surface the risk (
force-push needed) and let user decide - Never force-push here. Pushed branch rebased -> tell user
git push --force-with-lease. Let user run - Never
git rebase --skip/ drop commits to "make it work". Surface conflict - Never
--no-verify. Why -> hooks gate broken state; skipping just defers the failure - No upstream -> sync vs
origin/<base>. Note branch not pushed - Pop stash you made on rebase clean OR abort. Pop blocked by conflicts -> leave stashed + tell user
In this repository21 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- blog-writeSkill
- cloudflare-hygieneSkill
- git-branch-cleanupSkill
- git-branch-createSkill
- git-commitSkill
- git-issue-createSkill
- git-issue-startSkill
- git-issue-triageSkill
- git-pr-createSkill
- herdr-dispatchSkill
- humanizeSkill
- macos-cleanupSkill
- macos-maintenanceSkill
- obsidian-markdownSkill
- spec-applySkill
- spec-archiveSkill
- spec-exploreSkill
- spec-proposeSkill
- spec-verifySkill
- vercel-hygieneSkill
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.

