git-squash
Original:🇺🇸 English
Translated
Use when squash-merging a feature branch into main for linear history. Handles pre-flight checks, squash merge, commit delegation to git-commit, and branch cleanup.
12installs
Added on
NPX Install
npx skill4agent add ralphcrisostomo/nuxt-development-skills git-squashTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Git Squash
Pre-flight Checks
Before merging, validate the environment:
- Determine source branch — use the argument if provided (), otherwise use the current branch.
/git-squash feature/my-branch - Verify not on main — abort if source branch is .
main - Check for uncommitted changes — . If dirty, abort and suggest committing or stashing.
git status --porcelain - Verify branch exists — .
git rev-parse --verify <branch> - Verify divergence — . If empty, abort — nothing to merge.
git log main..<branch> --oneline
Switch to Main
bash
git checkout mainIf remote exists, pull latest with . If ff-only fails, abort — main has diverged and needs manual resolution.
origingit pull --ff-onlySquash Merge
bash
git merge --squash <branch>On conflicts: , switch back to source branch, suggest , stop.
git merge --abortgit rebase mainDelegate to git-commit
Invoke to handle the commit. Do not write commit messages directly.
/git-commitPost-merge Verification
bash
git log --oneline -5
git status
git diffConfirm: clean working tree, squash commit at HEAD, no leftover staged changes.
Cleanup
Try safe delete first:
bash
git branch -d <branch>If fails (expected — squash merges don't preserve ancestry), verify zero diff with . If empty, force-delete with . If there IS a diff, stop — something was lost.
-dgit diff main <branch>git branch -D <branch>If a remote tracking branch exists ():
git ls-remote --heads origin <branch>bash
git push origin --delete <branch>Rules
- Proceed without confirmation — pre-flight checks are the safety gate.
- Only merge into .
main - Always use — never fast-forward or regular merge.
--squash - Always delegate the commit to .
/git-commit - Abort on merge conflicts — never auto-resolve.
- Never force-push.
- Prefer — use
git branch -donly after verifying zero diff.-D - If any step fails, stop and report the error.
Quick Reference
Pre-flight → checkout main → → → verify → cleanup (, fall back to after zero diff check, delete remote if exists).
git merge --squash/git-commit-d-D