<< All versions
Skill v1.0.1
currentAutomated scan100/100rohitg00/awesome-claude-code-toolkit/git-advanced
1 files
──Details
PublishedMay 20, 2026 at 01:30 PM
Content Hashsha256:c73729b00678af67...
Git SHAebdf1d596d2c
Bump Typepatch
──Files
Files (1 file, 4.2 KB)
SKILL.md4.2 KBactive
SKILL.md · 171 lines · 4.2 KB
version: "1.0.1" name: git-advanced description: Advanced git workflows including worktrees, bisect, interactive rebase, hooks, and recovery techniques
Git Advanced
Worktrees
bash
# Create a worktree for a feature branch (avoids stashing)git worktree add ../feature-auth feature/auth# Create a worktree with a new branchgit worktree add ../hotfix-123 -b hotfix/123 origin/main# List all worktreesgit worktree list# Remove a worktree after merginggit 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
bash
# Start bisect, mark current as bad and known good commitgit bisect startgit bisect bad HEADgit bisect good v1.5.0# Git checks out a midpoint commit. Test it, then mark:git bisect good # if this commit worksgit bisect bad # if this commit is broken# Automate with a test scriptgit bisect start HEAD v1.5.0git bisect run npm test# When done, resetgit 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
bash
# Rebase last 5 commits interactivelygit 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 maingit fetch origingit rebase origin/main# Continue after resolving conflictsgit rebase --continue# Abort if things go wronggit rebase --abort
Git Hooks
bash
#!/bin/sh# .git/hooks/pre-commit# Run linter on staged files onlySTAGED_FILES=$(git diff --cached --name-only --diff-filter=d | grep -E '\.(ts|tsx|js|jsx)$')if [ -n "$STAGED_FILES" ]; thennpx eslint $STAGED_FILES --fixgit add $STAGED_FILESfi
bash
#!/bin/sh# .git/hooks/commit-msg# Enforce conventional commit formatCOMMIT_MSG=$(cat "$1")PATTERN="^(feat|fix|docs|style|refactor|test|chore)(\(.+\))?: .{1,72}$"if ! echo "$COMMIT_MSG" | head -1 | grep -qE "$PATTERN"; thenecho "Error: Commit message must follow Conventional Commits format"echo "Example: feat(auth): add OAuth2 login flow"exit 1fi
bash
#!/bin/sh# .git/hooks/pre-push# Run tests before pushingnpm testif [ $? -ne 0 ]; thenecho "Tests failed. Push aborted."exit 1fi
Recovery Techniques
bash
# Undo last commit but keep changes stagedgit reset --soft HEAD~1# Recover a deleted branch using refloggit refloggit checkout -b recovered-branch HEAD@{3}# Recover a file from a specific commitgit checkout abc1234 -- path/to/file.ts# Find lost commits (dangling after reset or rebase)git fsck --lost-foundgit show <dangling-commit-sha># Undo a rebasegit refloggit reset --hard HEAD@{5} # point before rebase started
Useful Aliases
bash
# ~/.gitconfig[alias]lg = log --graph --oneline --decorate --allst = status -sbco = checkoutunstage = reset HEAD --last = log -1 HEAD --statbranches = branch -a --sort=-committerdatestash-all = stash push --include-untrackedconflicts = 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 reviewinggit diff --staged - Not using
.gitignorefor 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 runautomates 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-leaseused instead of--forcewhen force-pushing - [ ] Reflog consulted before any destructive operation
- [ ]
.gitignorecovers build outputs, dependencies, and environment files