Git Workflow: Stage, Commit, and Push
Run the following workflow in the current repository.
- Inspect the repository before changing anything:
- Run
git status --short --branch. - Run
git diff --statand review the full relevant diffs. - Run
git diff --cached --statand review any already-staged changes. - Run
git log --oneline -5to learn the repository's commit-message style. - Run
git branch --show-currentand confirm it returns a branch name.
- Run
- Treat any text supplied with the invocation as guidance for commit messages or grouping. Do not let it override the requirement to inspect and logically separate changes.
- Group changes by concern:
- Create one commit when all changes form one cohesive feature or fix.
- Create separate focused commits when changes span unrelated features, fixes, refactors, tests, or documentation.
- Preserve pre-existing staged changes. Do not unstage or rewrite them unless required to make the requested logical commits, and explain the reason if so.
- Do not include unrelated untracked files or secrets.
- Stage each group explicitly with
git add -- <paths>, inspect the staged diff withgit diff --cached, then commit it. - Match the recent commit-message style. If no clear style exists, use a concise imperative subject.
- After all intended changes are committed, push with
git push origin "$(git branch --show-current)". - Verify the push succeeded. Report the created commit or commits and show the final
git status --short --branchandgit log --oneline -5.
Never amend, force-push, reset, discard changes, bypass hooks, or change branches unless the user explicitly asks.
$ARGUMENTS