| name | git-workflow |
| description | Git commit workflow. Load when finishing any code-change task (after verification) to commit and push, or when explicitly staging/committing. |
Git Workflow
Rules
- Never
git add -A
- Show diff before every commit
- Separate commits by logical change
- Commit automatically after review, then push the branch unless the user says not to.
- If a commit hook rewrites files, re-run
git add on the touched files before retrying the commit.
- Before switching branches or popping a stash, check for untracked files that may conflict with tracked paths on the target branch; back them up first if needed.
- If the task includes a PR description or plan, inspect
.github/pull_request_template.md and any relevant files in .github/
Commit Workflow
- Run
git diff --staged
- Run
git diff
- Run
git status and flag unrelated modified files
- Identify logical changes
- Stage intentionally (
git add <file> or git add -p)
- Run
git diff --staged to verify
- Commit with concise message (see below)
- Push the branch
- If push is rejected with
fetch first, run git fetch and git rebase onto the tracked branch, then retry
- Repeat for remaining changes
Commit Messages
- Subject line: max 72 characters
- Format:
type: description (e.g., feat: add mask function)
- No body/description unless absolutely needed
- No bullet points or paragraphs
- Keep it scannable in
git log
Multiple Commits
If unrelated changes exist, create multiple commits:
git add <files-for-commit-1>
git commit -m "type: description"
git add <files-for-commit-2>
git commit -m "type: description"
Undo
git reset HEAD~1
git reset --soft HEAD~1
Rebase gotcha: git rebase --continue hangs in pi bash
If EDITOR=nvim (or any TTY-bound editor) is set in the environment,
git rebase --continue will spawn that editor to confirm the commit message
and hang indefinitely in pi's non-interactive bash tool — the tool reports
"Command aborted" after the shell timeout, and git is left in a half-finished
rebase state.
Fix: bypass the editor with core.editor=true:
git -c core.editor=true rebase --continue
Equivalent: GIT_EDITOR=true git rebase --continue.
Apply this whenever --continue / --abort / --skip appear to hang. The same
applies to other git operations that spawn an editor (interactive rebase,
git commit without -m, git tag -a, etc.).