Git Task Commit & Push
You help the user commit and push work related to a specific task or ticket.
High-level flow
- •Understand the task scope.
- •Identify impacted files.
- •Stage only those files.
- •Show a summary and get confirmation.
- •Create a good commit message.
- •Push to the current branch.
Detailed procedure
- •
Clarify task
- •If $ARGUMENTS is present, treat it as the task ID or short description (e.g. "ABC-123 user settings bug").
- •If $ARGUMENTS is empty, ask the user to briefly describe the task or ticket ID.
- •
Inspect current changes
- •Run
git status -sb. - •Run
git diff(for unstaged changes) andgit diff --cached(for staged changes). - •Present a concise summary to the user, grouped by file.
- •Run
- •
Determine impacted files
- •Infer which files are related to the task from filenames, paths, and diff content.
- •List the candidate files and ask the user to confirm or adjust the selection.
- •Never stage files the user has explicitly excluded.
- •
Stage files
- •After confirmation, run
git add <file1> <file2> ...with the confirmed list. - •Avoid
git add -Aorgit add ..
- •After confirmation, run
- •
Prepare commit message
- •Analyze the diff for the staged files only (use
git diff --cached). - •Propose a concise, descriptive commit message (Conventional Commits style is preferred).
- •Show the proposed message and ask the user to confirm or edit it.
- •Analyze the diff for the staged files only (use
- •
Create commit (requires explicit approval)
- •Only after the user confirms both the staged files and the commit message:
- •Run
git commit -m "<final commit message>".
- •Run
- •If the commit fails (e.g. hooks), show the error and ask how to proceed.
- •Only after the user confirms both the staged files and the commit message:
- •
Push to remote (requires explicit approval)
- •Show the current branch (e.g.
git rev-parse --abbrev-ref HEAD) and the configured remote (e.g.git remote -v). - •Ask the user: "Do you want to push this commit to
<remote>/<branch>now?" - •Only if the user clearly agrees:
- •Run
git push(orgit push <remote> <branch>if necessary).
- •Run
- •If push fails (e.g. non-fast-forward), explain the error and ask how to proceed (do NOT force-push unless the user explicitly requests it).
- •Show the current branch (e.g.
Safety guidelines
- •Never modify git configuration.
- •Never run force pushes (
git push --forceor--force-with-lease) unless the user explicitly requests it in that turn. - •If anything is unclear about scope, ask the user for clarification instead of guessing.