git
Modern git workflows plus dispatched operations (rebase strategy analysis). Use when managing branches, structuring commits, choosing development strategies, or planning a rebase.
What this skill does
## Pre-loaded Context
Current branch:
!`git branch --show-current 2>/dev/null`
Status:
!`git status --short 2>/dev/null | head -10`
# Git Skill
Dispatches operations and provides reference knowledge for modern git workflows.
---
## Auto-Detect Rules
Apply these rules to `$ARGUMENTS` in order:
| Pattern | Route | Action |
|---|---|---|
| `rebase` (with or without args) | Rebase strategy | Read and follow [operations/rebase.md](operations/rebase.md) |
| No argument | Knowledge | Use sections below as reference |
> **Protocol:** [../dispatch/protocol.md](../dispatch/protocol.md)
---
## Menu Fallback
When no argument and the user wants an operation rather than reference, use **AskUserQuestion**:
```
Header: Git
Question: What would you like to do?
multiSelect: false
Options:
- Rebase: Analyze branch state and recommend a rebase strategy (--onto, autosquash, etc.)
- Reference: Show modern git workflow knowledge below
```
| Selection | Action |
|---|---|
| Rebase | Read and follow [operations/rebase.md](operations/rebase.md) |
| Reference | Continue with sections below |
---
# Modern Git Workflows
Trunk-based development with short-lived branches, squash merges, and modern git tooling.
---
## Development Model
**Trunk-based with short-lived branches:**
- `main` is always deployable
- Branch per feature/fix, squash merge back
- Branches live hours to days, not weeks
- Merge often — pain comes from divergence
**Branch naming:** `<type>/<short-description>` (e.g., `feat/auth`, `fix/null-check`, `chore/deps`)
---
## Quick Reference
**Modern command replacements:**
| Legacy | Modern | Why |
|--------|--------|-----|
| `git checkout <branch>` | `git switch <branch>` | Dedicated branch switching |
| `git checkout -b <branch>` | `git switch -c <branch>` | Explicit create-and-switch |
| `git checkout -- <file>` | `git restore <file>` | Dedicated file restoration |
| `git checkout HEAD -- <file>` | `git restore -s HEAD <file>` | Restore from specific ref |
| `git stash` | `git stash push -m "msg"` | Named stashes with pathspec |
| `git push --force` | `git push --force-with-lease` | Prevents overwriting others' work |
| `git log -p` | `git log --remerge-diff` | Shows merge conflict resolutions |
**Commit hygiene:**
```bash
git commit --fixup <sha> # Mark as fixup for <sha>
git rebase -i --autosquash main # Auto-fold fixups into targets
```
**Parallel workspaces:**
```bash
git worktree add ../feat-auth -b feat/auth
git worktree list
git worktree remove ../feat-auth
```
**Performance (large repos):**
```bash
git maintenance start # Background optimization
git sparse-checkout set src/ # Only checkout what you need
git clone --filter=blob:none # Partial clone (fetch blobs on demand)
```
**Conflict memory:**
```bash
git config rerere.enabled true # Remember conflict resolutions
```
---
## Cascading Branches
When features build on each other, cascade is natural. The discipline is in the rebase.
```
main: M1 - M2
\
A: A1 - A2 - A3
\
B: B1 - B2
```
**Rule:** Rebase downstream branches before the upstream ref changes identity (squash merge, force-push, delete).
```bash
# After squash-merging A into main:
git switch B
git rebase --onto main A # Replays B1-B2 onto main, skipping A's commits
# Then delete A
git branch -d A
```
**Merge the chain bottom-up:** merge A, rebase B onto main, merge B, rebase C onto main.
See [reference/branching.md](reference/branching.md) for details.
---
## Modern Features Worth Knowing
| Feature | Since | Use Case |
|---------|-------|----------|
| `switch` / `restore` | 2.23 | Replace overloaded `checkout` |
| `--force-with-lease` | 2.13 | Safe force push |
| `commit --fixup` | 2.32+ | Amend past commits without interactive rebase |
| `range-diff` | 2.19 | Compare rebase before/after |
| `worktree` | 2.5+ | Parallel branch work without stashing |
| `maintenance` | 2.29 | Background gc, prefetch, commit-graph |
| `sparse-checkout` | 2.25 | Large monorepo subset |
| `--filter=blob:none` | 2.19 | Partial clone |
| `blame --ignore-rev` | 2.23 | Skip formatting commits in blame |
| `diff --color-moved` | 2.17 | Distinguish moved vs changed code |
| `rerere` | old | Reuse recorded merge resolutions |
| `log --remerge-diff` | 2.35 | Show what a merge actually resolved |
See [reference/commands.md](reference/commands.md) and [reference/history.md](reference/history.md) for patterns.
---
## Anti-Patterns
- Squash merging a branch while downstream branches depend on it (rebase first)
- Long-lived feature branches (merge often, keep branches short)
- `git push --force` without `--lease` (overwrites others' work)
- Using `checkout` for both branch switching and file restoration
- Manual fixup of past commits (use `--fixup` + `--autosquash`)
- Deleting upstream branch before rebasing downstream branches
- Inverting `rebase --onto` direction — the checked-out branch becomes a descendant of `<new-base>`, not the other way around. State intent in one sentence ("X will sit on top of Y") before running.
- Committing, force-pushing, or squash-merging on top of a rebase without first verifying topology (`git log --oneline --graph <base>..HEAD`). A misrouted rebase is recoverable; a squash-merge of a misrouted branch into an integration ref is not.
---
## Related Skills
- **bash**: Shell command patterns
- **issue**: GitHub issue operations (create PRs, link issues to branches)
---
## Operations
- [operations/rebase.md](operations/rebase.md) - Branch state analysis and rebase strategy recommendation
## Reference
- [reference/branching.md](reference/branching.md) - Cascading branch patterns
- [reference/commands.md](reference/commands.md) - Command patterns
- [reference/history.md](reference/history.md) - History management
- [reference/worktree.md](reference/worktree.md) - Worktree creation with safety checks
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.