| name | recommit |
| description | Reshape all commits in the current branch into clean atomic commits. Soft-resets all branch commits back to working tree, then re-commits as logical groups following make-commit convention. Rewrites history — asks for confirmation first. Use when: user says 'recommit', 'переделай коммиты', 'rewrite commits', 'squash and split', 'reorganize commits', or wants to redo/restructure existing branch commits. |
recommit
Reshape all commits in the current branch. Uncommits all changes back to local changes, then creates new atomic commits following make_commit rules.
Commit Format
<branch-name>: Short description in English
More detailed description of the changes.
Branch name is determined via git branch --show-current.
Instructions
- Find branch divergence point:
- Get current branch name via
git branch --show-current
- Find commits not in main:
git log --oneline --first-parent main..HEAD
- Count determines the base point:
HEAD~<count>
- CRITICAL — Confirm before uncommit:
- Preserve changes: Run
git reset --soft HEAD~<count> to uncommit but keep changes staged
- Unstage changes: Run
git reset HEAD to move all changes to unstaged
- Analyze changes: Review all modified and new files via
git status and git diff
- Group by context: Split changes into logical groups
- Create atomic commits: Each commit should contain only related changes from one context
- Prefix: Use current branch name as commit prefix
- Subject line: Short description (up to 72 chars)
- Commit body: Detailed description
Rules
- Warning: This command rewrites commit history!
- One commit = one context of changes
- Do not mix refactoring with new features
- Do not include unrelated files in one commit
- Descriptions in English
- Uses
git log --first-parent main..HEAD to determine branch commits
Post-commit cleanup
After creating all new atomic commits:
-
Verify created commits:
git log main..HEAD --format="%H%n%B%n---"
-
Find and remove Co-Authored-By if present:
git commit --amend -m "$(git log -1 --format=%B | sed '/^Co-Authored-By:/,$d')"
Critical:
- Cleanup happens AFTER all atomic commits are created
- Check ALL commits in the branch (relative to main)
- Remove the entire footer starting from "Co-Authored-By:"