# GIT Advanced

Advanced git workflows including worktrees, bisect, interactive rebase, hooks, and...

- Repository: https://github.com/rohitg00/awesome-claude-code-toolkit (2800 stars)
- Category: Git and review
- License: Apache-2.0
- Last updated: 2026-05-12
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add rohitg00/awesome-claude-code-toolkit --skill git-advanced -g -a claude-code -y`
Codex: `npx skills add rohitg00/awesome-claude-code-toolkit --skill git-advanced -g -a codex -y`
Cursor: `npx skills add rohitg00/awesome-claude-code-toolkit --skill git-advanced -g -a cursor -y`
Gemini CLI: `npx skills add rohitg00/awesome-claude-code-toolkit --skill git-advanced -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add rohitg00/awesome-claude-code-toolkit`

## Description

Advanced git workflows including worktrees, bisect, interactive rebase, hooks, and recovery techniques

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# 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 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

```bash
# 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

```bash
# 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

```bash
#!/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
```

```bash
#!/bin/sh
# .git/hooks/commit-msg

The rest: https://github.com/rohitg00/awesome-claude-code-toolkit/blob/HEAD/skills/git-advanced/SKILL.md
