/git-advanced
Advanced git workflows including worktrees, bisect, interactive rebase, hooks, and recovery techniques
$ npx -y skills add rohitg00/awesome-claude-code-toolkit --skill git-advanced --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/git-advanced
Context preview
The summary Claude sees to decide when to auto-load this skill.
Advanced git workflows including worktrees, bisect, interactive rebase, hooks, and recovery techniques
SKILL.md
git-advanced.SKILL.mdname: git-advanced
description: Advanced git workflows including worktrees, bisect, interactive rebase, hooks, and recovery techniques
Git Advanced
Worktrees
# Create a worktree for a feature branch (avoids stashing)
git worktree add ../feature-auth feature/auth
# Create a worktree with a new branch
git worktree add ../hotfix-123 -b hotfix/123 origin/main
# List all worktrees
git worktree list
# Remove a worktree after merging
git worktree remove ../feature-auth
Worktrees let you work on multiple branches simultaneously without stashing or committing WIP. Each worktree has its own working directory but shares the same `.git` repository.
Bisect
# Start bisect, mark current as bad and known good commit
git bisect start
git bisect bad HEAD
git bisect good v1.5.0
# Git checks out a midpoint commit. Test it, then mark:
git bisect good # if this commit works
git bisect bad # if this commit is broken
# Automate with a test script
git bisect start HEAD v1.5.0
git bisect run npm test
# When done, reset
git bisect reset
Bisect performs binary search across commits to find which commit introduced a bug. Automated bisect with `run` is the fastest approach.
Interactive Rebase
# Rebase last 5 commits interactively
git rebase -i HEAD~5
# Common operations in the editor:
# pick - keep commit as-is
# reword - change commit message
# edit - stop to amend the commit
# squash - merge into previous commit, keep both messages
# fixup - merge into previous commit, discard this message
# drop - remove the commit entirely
# Rebase feature branch onto latest main
git fetch origin
git rebase origin/main
# Continue after resolving conflicts
git rebase --continue
# Abort if things go wrong
git rebase --abort
Git Hooks
#!/bin/sh
# .git/hooks/pre-commit
# Run linter on staged files only
STAGED_FILES=$(git diff --cached --name-only --diff-filter=d | grep -E '\.(ts|tsx|js|jsx)$')
if [ -n "$STAGED_FILES" ]; then
npx eslint $STAGED_FILES --fix
git add $STAGED_FILES
fi
#!/bin/sh
# .git/hooks/commit-msg
# Enforce conventional commit format
COMMIT_MSG=$(cat "$1")
PATTERN="^(feat|fix|docs|style|refactor|test|chore)(\(.+\))?: .{1,72}$"
if ! echo "$COMMIT_MSG" | head -1 | grep -qE "$PATTERN"; then
echo "Error: Commit message must follow Conventional Commits format"
echo "Example: feat(auth): add OAuth2 login flow"
exit 1
fi#!/bin/sh
# .git/hooks/pre-push
# Run tests before pushing
npm test
if [ $? -ne 0 ]; then
echo "Tests failed. Push aborted."
exit 1
fi
Recovery Techniques
# Undo last commit but keep changes staged
git reset --soft HEAD~1
# Recover a deleted branch using reflog
git reflog
git checkout -b recovered-branch HEAD@{3}
# Recover a file from a specific commit
git checkout abc1234 -- path/to/file.ts
# Find lost commits (dangling after reset or rebase)
git fsck --lost-found
git show <dangling-commit-sha>
# Undo a rebase
git reflog
git reset --hard HEAD@{5} # point before rebase startedUseful Aliases
# ~/.gitconfig
[alias]
lg = log --graph --oneline --decorate --all
st = status -sb
co = checkout
unstage = reset HEAD --
last = log -1 HEAD --stat
branches = branch -a --sort=-committerdate
stash-all = stash push --include-untracked
conflicts = diff --name-only --diff-filter=U
Anti-Patterns
- Force-pushing to shared branches without `--force-with-lease`
- Rebasing commits that have already been pushed and shared
- Committing large binary files without Git LFS
- Using `git add .` without reviewing `git diff --staged`
- Not using `.gitignore` for build artifacts, dependencies, and secrets
- Keeping long-lived feature branches instead of merging frequently
Checklist
- [ ] Worktrees used for parallel branch work instead of stashing
- [ ] `git bisect run` automates bug-finding with a test command
- [ ] Interactive rebase cleans up commits before merging to main
- [ ] Pre-commit hooks run linting on staged files
- [ ] Commit message format enforced via commit-msg hook
- [ ] `--force-with-lease` used instead of `--force` when force-pushing
- [ ] Reflog consulted before any destructive operation
- [ ] `.gitignore` covers build outputs, dependencies, and environment files
Read more
name: git-advanced description: Advanced git workflows including worktrees, bisect, interactive rebase, hooks, and recovery techniques
Git Advanced
Worktrees
# Create a worktree for a feature branch (avoids stashing) git worktree add ../feature-auth feature/auth # Create a worktree with a new branch git worktree add ../hotfix-123 -b hotfix/123 origin/main # List all worktrees git worktree list # Remove a worktree after merging git worktree remove ../feature-auth
Worktrees let you work on multiple branches simultaneously without stashing or committing WIP. Each worktree has its own working directory but shares the same `.git` repository.
Bisect
# Start bisect, mark current as bad and known good commit git bisect start git bisect bad HEAD git bisect good v1.5.0 # Git checks out a midpoint commit. Test it, then mark: git bisect good # if this commit works git bisect bad # if this commit is broken # Automate with a test script git bisect start HEAD v1.5.0 git bisect run npm test # When done, reset git bisect reset
Bisect performs binary search across commits to find which commit introduced a bug. Automated bisect with `run` is the fastest approach.
Interactive Rebase
# Rebase last 5 commits interactively git rebase -i HEAD~5 # Common operations in the editor: # pick - keep commit as-is # reword - change commit message # edit - stop to amend the commit # squash - merge into previous commit, keep both messages # fixup - merge into previous commit, discard this message # drop - remove the commit entirely # Rebase feature branch onto latest main git fetch origin git rebase origin/main # Continue after resolving conflicts git rebase --continue # Abort if things go wrong git rebase --abort
Git Hooks
#!/bin/sh # .git/hooks/pre-commit # Run linter on staged files only STAGED_FILES=$(git diff --cached --name-only --diff-filter=d | grep -E '\.(ts|tsx|js|jsx)$') if [ -n "$STAGED_FILES" ]; then npx eslint $STAGED_FILES --fix git add $STAGED_FILES fi
#!/bin/sh
# .git/hooks/commit-msg
# Enforce conventional commit format
COMMIT_MSG=$(cat "$1")
PATTERN="^(feat|fix|docs|style|refactor|test|chore)(\(.+\))?: .{1,72}$"
if ! echo "$COMMIT_MSG" | head -1 | grep -qE "$PATTERN"; then
echo "Error: Commit message must follow Conventional Commits format"
echo "Example: feat(auth): add OAuth2 login flow"
exit 1
fi#!/bin/sh # .git/hooks/pre-push # Run tests before pushing npm test if [ $? -ne 0 ]; then echo "Tests failed. Push aborted." exit 1 fi
Recovery Techniques
# Undo last commit but keep changes staged
git reset --soft HEAD~1
# Recover a deleted branch using reflog
git reflog
git checkout -b recovered-branch HEAD@{3}
# Recover a file from a specific commit
git checkout abc1234 -- path/to/file.ts
# Find lost commits (dangling after reset or rebase)
git fsck --lost-found
git show <dangling-commit-sha>
# Undo a rebase
git reflog
git reset --hard HEAD@{5} # point before rebase startedUseful Aliases
# ~/.gitconfig [alias] lg = log --graph --oneline --decorate --all st = status -sb co = checkout unstage = reset HEAD -- last = log -1 HEAD --stat branches = branch -a --sort=-committerdate stash-all = stash push --include-untracked conflicts = diff --name-only --diff-filter=U
Anti-Patterns
- Force-pushing to shared branches without `--force-with-lease`
- Rebasing commits that have already been pushed and shared
- Committing large binary files without Git LFS
- Using `git add .` without reviewing `git diff --staged`
- Not using `.gitignore` for build artifacts, dependencies, and secrets
- Keeping long-lived feature branches instead of merging frequently
Checklist
- [ ] Worktrees used for parallel branch work instead of stashing
- [ ] `git bisect run` automates bug-finding with a test command
- [ ] Interactive rebase cleans up commits before merging to main
- [ ] Pre-commit hooks run linting on staged files
- [ ] Commit message format enforced via commit-msg hook
- [ ] `--force-with-lease` used instead of `--force` when force-pushing
- [ ] Reflog consulted before any destructive operation
- [ ] `.gitignore` covers build outputs, dependencies, and environment files
The most comprehensive toolkit for Claude Code -- 135 agents, 35 curated skills (+400,000 via SkillKit), 42 commands, 176+ plugins, 20 hooks, 15 rules, 7 templates, 15 MCP configs, 26 companion apps, 53 ecosystem entries, and more.
Repo: rohitg00/awesome-claude-code-toolkit
Other skills on rohitg00-claude-code-toolkit.
- /accessibility-wcag
Web accessibility patterns for WCAG 2.2 compliance including ARIA, keyboard navigation, screen readers, and testing
Open skill - /agentkit-seo
Route broad or ambiguous AgentKit SEO work to the right module while keeping context scoped. Use when a request spans multiple surfaces, asks for overall digital-presence strategy, involves provider or install architecture, needs agent-context planning, or the correct platform
Open skill - /api-design-patterns
REST API design with resource naming, pagination, versioning, and OpenAPI spec generation
Open skill - /authentication-patterns
Authentication and authorization patterns including OAuth2, JWT, RBAC, session management, and PKCE flows
Open skill - /aws-cloud-patterns
AWS cloud patterns for Lambda, ECS, S3, DynamoDB, and Infrastructure as Code with CDK/Terraform
Open skill - /ci-cd-pipelines
CI/CD pipeline patterns for GitHub Actions, GitLab CI, testing strategies, and deployment automation
Open skill

