SKILL.md 1.9 KB

git-commit-push

Git commit and push quick reference for this repository.

Use this skill when the task is about staging changes, creating commits, pushing branches, amending commits, stashing work, or inspecting git history.

Basic Flow

Inspect changes

git status
git diff
git diff --cached

Stage changes

git add .
git add <path>
git add -p

Commit

git commit -m "feat: short summary"
git commit
git commit -am "fix: short summary"

Push

git push
git push origin main
git push -u origin <branch>
git push --force-with-lease

Amend

git commit --amend -m "new message"
git add <missed-file>
git commit --amend --no-edit

If the amended commit has already been pushed:

git push --force-with-lease

Undo and Restore

Prefer non-destructive commands unless the user explicitly asks otherwise.

Unstage

git restore --staged <path>
git reset HEAD <path>

Discard worktree changes

git restore <path>

Undo commits while keeping changes

git reset --soft HEAD~1
git reset HEAD~1

Avoid git reset --hard unless the user explicitly requests destructive history/worktree reset.

Stash

git stash
git stash -u
git stash list
git stash pop
git stash apply stash@{0}
git stash drop stash@{0}

History

git log
git log --oneline
git log --graph --oneline --all
git log -n 5
git log <path>

Conflict Handling

git status
git checkout --ours <path>
git checkout --theirs <path>
git add <path>
git commit -m "resolve merge conflict"
git merge --abort

Commit Message Guidance

  • Prefer conventional prefixes such as feat:, fix:, refactor:, docs:, test:, chore:.
  • Keep the first line concise and user-impact oriented.
  • Do not amend or force-push unless the user asked for it or the workflow clearly requires it.