---
name: git-upload
description: Upload local project changes to a git remote safely. Use when asked to stage changes, create commit(s), and push to origin (or another remote), including branch checks, commit message quality, and conflict-safe push workflow.
---

# Git Upload

## Overview
Prepare, commit, and push code changes safely with minimal risk. Prefer clear commits and non-destructive git operations.

## Workflow
1. Inspect repository state.
- Run `git status --short --branch`.
- Identify changed files and confirm target branch.

2. Validate what should be uploaded.
- Exclude unintended files (secrets, generated junk, local env files).
- Keep commit scope focused.

3. Stage changes.
- Stage specific files when possible (`git add <paths>`).
- Use `git add -A` only when user wants all changes.

4. Commit with quality message.
- Format: short imperative summary.
- Include optional body when context is important.
- Example: `feat(settings): read payment config from db-backed keys`

5. Sync before push (safe path).
- If needed, fetch and rebase/pull according to project policy.
- Resolve conflicts before pushing.

6. Push.
- Use `git push origin <branch>`.
- Do not force push unless explicitly requested.

7. Report result.
- Return branch name, commit hash, and pushed status.

## Safety Rules
- Never run destructive commands (`reset --hard`, force push) unless explicitly requested.
- If branch is protected or push fails, explain exact blocker and next command.
- If there are unrelated changes, separate them into a different commit unless user asks otherwise.

## Output Expectations
When done, provide:
- branch pushed
- commit hash + message
- whether remote push succeeded
- any follow-up action needed (PR creation, conflict resolution)
