| 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
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.).
Fixing a PR's merge conflicts
For cross-fork PRs (isCrossRepository: true), git push origin <branch> does
NOT update the PR — it only creates a new branch on the base repo. To update the
PR, push to the contributor's fork:
gh pr view <N> --repo <org>/<repo> --json maintainerCanModify
git push git@github.com:<contributor>/<repo>.git <local>:<pr-branch>
In a git merge, --ours = current branch, --theirs = branch being merged in
(opposite of git checkout's --ours/--theirs semantics in rebase).