| name | git |
| description | Git version control best practices for AI coding agents. Covers branching, committing, conflict resolution, worktree management, and safe git operations. |
Git Skill
You are working with Git in an automated workflow context. Follow these guidelines for all Git operations.
General Principles
- Never force push to shared branches (main, master, develop).
- Never use
git push --force unless explicitly instructed.
- Never skip hooks (
--no-verify) unless explicitly instructed.
- Always commit before switching branches if there are uncommitted changes.
- Check current branch before any commit or push operation.
- Prefer creating new commits over amending existing ones, unless explicitly told to amend.
Branch Management
Creating Branches
git checkout -b <branch-name>
Checking State
git status
git branch -a
git log --oneline -10
git diff --stat
Committing
Commit Messages
Follow the repository's existing commit message convention. Check git log --oneline -10 first.
If no clear convention exists, use:
<type>(<scope>): <description>
[optional body]
Types: feat, fix, refactor, test, docs, chore, style, perf
Committing Workflow
git status
git diff
git diff --staged
git add path/to/file1.ts path/to/file2.ts
git commit -m "type(scope): description of change"
git log --oneline -1
git show --stat HEAD
What NOT to Commit
.env files or any file containing secrets/tokens/credentials
node_modules/ or build output directories
- IDE-specific files (
.idea/, .vscode/) unless already tracked
- Large binary files
- Database files (
.db, .sqlite)
Working with Worktrees
In this project, workflows use Git worktrees for isolation.
git worktree list
git worktree add <path> -b <branch-name>
git worktree remove <path>
git worktree remove --force <path>
Worktree Best Practices
- Each worktree gets its own branch. Do not reuse branches across worktrees.
- Clean up worktrees when workflow runs complete.
- Check
git worktree list before creating to avoid path conflicts.
Merging and Rebasing
Prefer Merge over Rebase
- Use
git merge for integrating branches. It preserves full history.
- Only use
git rebase when explicitly instructed and on local-only branches.
- Never rebase shared/public branches.
Conflict Resolution
git status
git add <resolved-file>
git merge --continue
git merge --abort
Stashing
git stash push -m "description of stash"
git stash list
git stash pop
git stash apply stash@{0}
Syncing with Remote
git fetch origin
git pull --rebase origin <branch>
git push origin <branch>
git push -u origin <branch>
Undoing Changes (Safe Methods)
git restore --staged <file>
git restore <file>
git reset --soft HEAD~1
git show <commit-hash>
Pre-commit and Hooks
- Never skip pre-commit hooks (
--no-verify) unless explicitly instructed.
- If a hook fails, investigate and fix the underlying issue.
- Pre-commit hooks often run linting, formatting, or type checks.