1---2name: git-guide3description: Use when running git operations or resolving repo-state issues. Triggers on prompts about commit messages, conventional commits (feat/fix/chore/docs), merge conflicts, rebases, worktrees, feature-worktree create / merge / abandon / cleanup, branch cleanup, or history rewrites, even when the user doesn't say 'git'.4---56# Git Guidelines78## Core Principles910- **Conventional Commits** - Use type prefixes (feat, fix, chore, docs, refactor, test, ci), see [references/commit.md](references/commit.md)11- **Auto-Generate Messages** - Analyze changed files and context, see [references/commit.md](references/commit.md)12- **Isolated Development** - Use worktrees for feature branches, see [references/worktree-create.md](references/worktree-create.md)13- **Validate Before Merge** - Run typecheck/lint/build/test, see [references/worktree-validate.md](references/worktree-validate.md)14- **Publish and Rebase** - Push a branch upstream and rebase onto the base before opening a PR / MR, see [references/push.md](references/push.md)15- **Explicit Effects** - Worktree create, merge, and cleanup default to preview and mutate only for an explicit apply1617## Commit Operations1819- **Auto-commit** - Analyze changes, infer type, generate message, optional push, see [references/commit.md](references/commit.md)2021## Branch Operations2223- **Push + rebase-onto-base** - Publish a branch upstream and keep its PR / MR diff just this change; the host skill (`github-guide` / `gitlab-guide`) drives the PR itself, see [references/push.md](references/push.md)2425## Conflict Resolution2627- **Detect and classify** - Find conflicts, suggest strategy (ours/theirs/merge), see [references/merge-resolve.md](references/merge-resolve.md)28- **Validate** - Run typecheck/lint after resolution before staging, see [references/merge-resolve.md](references/merge-resolve.md)2930## Worktree Operations3132- **Create** - Preview or apply creation of a `<worktree>-feature-<name>` directory and branch, see [references/worktree-create.md](references/worktree-create.md)33- **Validate** - Pre-merge validation checkpoint, see [references/worktree-validate.md](references/worktree-validate.md)34- **Merge** - Preview or apply integration into the source branch without cleanup, see [references/worktree-merge.md](references/worktree-merge.md)35- **Cleanup** - Preview or apply removal of exact stale or merged targets, see [references/worktree-cleanup.md](references/worktree-cleanup.md)36- **Abandon** - Inspect and document a stopped feature without mutation, see [references/worktree-abandon.md](references/worktree-abandon.md)3738## Gotchas3940- `git pull` is `fetch` + `merge`, on a shared branch this creates spurious merge commits; prefer `pull --rebase` or `fetch` then explicit merge41- Detached HEAD: committing in this state silently loses commits when you `checkout` away. Note the SHA or branch immediately42- Hooks in `.git/hooks/` are not version-controlled: share via `core.hooksPath` pointing at a tracked directory43- A feature `worktree-merge` integrates a branch into its **parent** branch; landing on the mainline goes through push + PR + CI review, never a direct local merge to `main`44- Merge, abandon, and cleanup are separate operations, none may silently perform another45- Long-lived feature branches drift and conflict: keep them short-lived; integrate work spanning sessions incrementally behind feature flags / branch-by-abstraction46- Deleting a worktree directory by hand leaves a stale admin entry: run `git worktree prune`; and each worktree needs its own dependency install (`node_modules` is not shared across worktrees)4748## Progressive Disclosure4950### Commit Operations5152- Read [references/commit.md](references/commit.md) - Load when committing changes with auto-generated conventional messages53- Read [references/push.md](references/push.md) - Load when publishing a branch upstream and rebasing it onto the base before opening a PR / MR54- Read [references/merge-resolve.md](references/merge-resolve.md) - Load when detecting and resolving merge conflicts5556### Worktree Operations5758- Read [references/worktree-create.md](references/worktree-create.md) - Load when creating a feature worktree with branch59- Read [references/worktree-validate.md](references/worktree-validate.md) - Load when running pre-merge validation in a feature worktree60- Read [references/worktree-merge.md](references/worktree-merge.md) - Load when merging a feature worktree back to its source branch61- Read [references/worktree-cleanup.md](references/worktree-cleanup.md) - Load when removing stale or merged worktrees62- Read [references/worktree-abandon.md](references/worktree-abandon.md) - Load when documenting and removing an abandoned feature worktree