When to Use
Use when the task involves Git repositories, branches, commits, merges, rebases, pull requests, conflict resolution, history inspection, or recovery. This skill is stateless and should be applied by default whenever Git work is part of the job.
Quick Reference
| Topic |
File |
| Essential commands |
commands.md |
| Advanced operations |
advanced.md |
| Branch strategies |
branching.md |
| Conflict resolution |
conflicts.md |
| History and recovery |
history.md |
| Team workflows |
collaboration.md |
Core Rules
- Never force push to shared branches — Use
--force-with-lease on feature branches only
- Commit early, commit often — Small commits are easier to review, revert, and bisect
- Write meaningful commit messages — First line under 72 chars, imperative mood
- Pull before push — Always
git pull --rebase before pushing to avoid merge commits
- Clean up before merging — Use
git rebase -i to squash fixup commits
Team Workflows
Feature Branch Flow:
git checkout -b feature/name from main
- Make commits, push regularly
- Open PR, get review
- Squash and merge to main
- Delete feature branch
Hotfix Flow:
git checkout -b hotfix/issue from main
- Fix, test, commit
- Merge to main AND develop (if exists)
- Tag the release
Daily Sync:
git fetch --all --prune
git rebase origin/main # or merge if team prefers
Commit Messages
- Use conventional commit format:
type(scope): description
- Keep first line under 72 characters
- Types:
feat, fix, docs, style, refactor, test, chore
Push Safety
- Use
git push --force-with-lease instead of --force — prevents overwriting others' work
- If push rejected, run
git pull --rebase before retrying
- Never force push to main/master branch
Conflict Resolution
- After editing conflicted files, verify no markers remain:
grep -r "<<<\|>>>\|===" .
- Test that code builds before completing merge
- If merge becomes complex, abort with
git merge --abort and try git rebase instead
Branch Hygiene
- Delete merged branches locally:
git branch -d branch-name
- Clean remote tracking:
git fetch --prune
- Before creating PR, rebase feature branch onto latest main
- Use
git rebase -i to squash messy commits before pushing
Safety Checklist
Before destructive operations (reset --hard, rebase, force push):
Common Traps
- git user.email wrong — Verify with
git config user.email before important commits
- Empty directories — Git doesn't track them, add
.gitkeep
- Submodules — Always clone with
--recurse-submodules
- Detached HEAD — Use
git switch - to return to previous branch
- Push rejected — Usually needs
git pull --rebase first
- stash pop on conflict — Stash disappears. Use
stash apply instead
- Large files — Use Git LFS for files >50MB, never commit secrets
- Case sensitivity — Mac/Windows ignore case, Linux doesn't — causes CI failures
Recovery Commands
- Undo last commit keeping changes:
git reset --soft HEAD~1
- Discard unstaged changes:
git restore filename
- Find lost commits:
git reflog (keeps ~90 days of history)
- Recover deleted branch:
git checkout -b branch-name <sha-from-reflog>
- Use
git add -p for partial staging when commit mixes multiple changes
Quick Summary
git status -sb # short status with branch
git log --oneline -5 # last 5 commits
git shortlog -sn # contributors by commit count
git diff --stat HEAD~5 # changes summary last 5 commits
git branch -vv # branches with tracking info
git stash list # pending stashes
Related Skills
Install with clawhub install <slug> if user confirms:
gitlab — GitLab CI/CD and merge requests
docker — Containerization workflows
code — Code quality and best practices
Feedback
- If useful:
clawhub star git
- Stay updated:
clawhub sync
1---2name: git3description: Git commits, branches, rebases, merges, conflict resolution, history recovery, team workflows, and the commands needed for safe day-to-day version control. Use when (1) the task touches Git, a repository, commits, branches, merges, rebases, or pull requests; (2) history safety, collaboration, or recovery matter; (3) the agent should automatically apply Git discipline instead of improvising.4---56## When to Use78Use when the task involves Git repositories, branches, commits, merges, rebases, pull requests, conflict resolution, history inspection, or recovery. This skill is stateless and should be applied by default whenever Git work is part of the job.910## Quick Reference1112| Topic | File |13|-------|------|14| Essential commands | `commands.md` |15| Advanced operations | `advanced.md` |16| Branch strategies | `branching.md` |17| Conflict resolution | `conflicts.md` |18| History and recovery | `history.md` |19| Team workflows | `collaboration.md` |2021## Core Rules22231. **Never force push to shared branches** — Use `--force-with-lease` on feature branches only242. **Commit early, commit often** — Small commits are easier to review, revert, and bisect253. **Write meaningful commit messages** — First line under 72 chars, imperative mood264. **Pull before push** — Always `git pull --rebase` before pushing to avoid merge commits275. **Clean up before merging** — Use `git rebase -i` to squash fixup commits2829## Team Workflows3031**Feature Branch Flow:**321. `git checkout -b feature/name` from main332. Make commits, push regularly343. Open PR, get review354. Squash and merge to main365. Delete feature branch3738**Hotfix Flow:**391. `git checkout -b hotfix/issue` from main402. Fix, test, commit413. Merge to main AND develop (if exists)424. Tag the release4344**Daily Sync:**45```bash46git fetch --all --prune47git rebase origin/main # or merge if team prefers48```4950## Commit Messages5152- Use conventional commit format: `type(scope): description`53- Keep first line under 72 characters54- Types: `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore`5556## Push Safety5758- Use `git push --force-with-lease` instead of `--force` — prevents overwriting others' work59- If push rejected, run `git pull --rebase` before retrying60- Never force push to main/master branch6162## Conflict Resolution6364- After editing conflicted files, verify no markers remain: `grep -r "<<<\|>>>\|===" .`65- Test that code builds before completing merge66- If merge becomes complex, abort with `git merge --abort` and try `git rebase` instead6768## Branch Hygiene6970- Delete merged branches locally: `git branch -d branch-name`71- Clean remote tracking: `git fetch --prune`72- Before creating PR, rebase feature branch onto latest main73- Use `git rebase -i` to squash messy commits before pushing7475## Safety Checklist7677Before destructive operations (`reset --hard`, `rebase`, `force push`):7879- [ ] Is this a shared branch? → Don't rewrite history80- [ ] Do I have uncommitted changes? → Stash or commit first81- [ ] Am I on the right branch? → `git branch` to verify82- [ ] Is remote up to date? → `git fetch` first8384## Common Traps8586- **git user.email wrong** — Verify with `git config user.email` before important commits87- **Empty directories** — Git doesn't track them, add `.gitkeep`88- **Submodules** — Always clone with `--recurse-submodules`89- **Detached HEAD** — Use `git switch -` to return to previous branch90- **Push rejected** — Usually needs `git pull --rebase` first91- **stash pop on conflict** — Stash disappears. Use `stash apply` instead92- **Large files** — Use Git LFS for files >50MB, never commit secrets93- **Case sensitivity** — Mac/Windows ignore case, Linux doesn't — causes CI failures9495## Recovery Commands9697- Undo last commit keeping changes: `git reset --soft HEAD~1`98- Discard unstaged changes: `git restore filename`99- Find lost commits: `git reflog` (keeps ~90 days of history)100- Recover deleted branch: `git checkout -b branch-name <sha-from-reflog>`101- Use `git add -p` for partial staging when commit mixes multiple changes102103## Quick Summary104105```bash106git status -sb # short status with branch107git log --oneline -5 # last 5 commits108git shortlog -sn # contributors by commit count109git diff --stat HEAD~5 # changes summary last 5 commits110git branch -vv # branches with tracking info111git stash list # pending stashes112```113114## Related Skills115Install with `clawhub install <slug>` if user confirms:116- `gitlab` — GitLab CI/CD and merge requests117- `docker` — Containerization workflows118- `code` — Code quality and best practices119120## Feedback121122- If useful: `clawhub star git`123- Stay updated: `clawhub sync`