Agent skill
git-advanced-1-interactive-rebase
Sub-skill of git-advanced: 1. Interactive Rebase (+1).
Install this agent skill to your Project
npx add-skill https://github.com/vamseeachanta/workspace-hub/tree/main/.claude/skills/_archive/operations/devtools/git-advanced/1-interactive-rebase
SKILL.md
1. Interactive Rebase (+1)
1. Interactive Rebase
Basic Interactive Rebase:
# Rebase last 5 commits
git rebase -i HEAD~5
# Rebase onto main
git rebase -i main
# Rebase from specific commit
git rebase -i abc123^
Interactive Rebase Commands:
pick abc123 First commit # Use commit as-is
reword def456 Second commit # Edit commit message
edit ghi789 Third commit # Stop to amend
squash jkl012 Fourth commit # Combine with previous
fixup mno345 Fifth commit # Combine, discard message
drop pqr678 Sixth commit # Remove commit
Common Rebase Workflows:
# Squash all commits into one
git rebase -i main
# Change all but first 'pick' to 'squash'
# Reorder commits
git rebase -i HEAD~3
# Rearrange the pick lines
# Split a commit
git rebase -i HEAD~3
# Change 'pick' to 'edit' on target commit
git reset HEAD^
git add -p # Add pieces
git commit -m "First part"
git add .
git commit -m "Second part"
git rebase --continue
# Edit commit message
git rebase -i HEAD~3
# Change 'pick' to 'reword'
Autosquash Pattern:
# Create fixup commit
git commit --fixup=abc123
# Create squash commit
git commit --squash=abc123
# Apply autosquash
git rebase -i --autosquash main
# Enable autosquash by default
git config --global rebase.autosquash true
2. Git Worktrees
Basic Worktree Usage:
# List worktrees
git worktree list
# Add worktree for existing branch
git worktree add ../feature-branch feature/new-feature
# Add worktree with new branch
git worktree add -b hotfix/urgent ../hotfix-urgent main
# Remove worktree
git worktree remove ../feature-branch
# Prune stale worktrees
git worktree prune
Worktree Workflow:
# Project structure
workspace/
├── main/ # Main development
├── feature-auth/ # Feature branch
├── hotfix-critical/# Hotfix branch
└── experiment/ # Experimental work
# Setup
cd main
git worktree add ../feature-auth feature/authentication
git worktree add ../hotfix-critical -b hotfix/critical-bug
git worktree add ../experiment -b experiment/new-approach
# Work on feature
cd ../feature-auth
# make changes...
git commit -am "Add authentication"
# Quick switch to fix bug
cd ../hotfix-critical
# fix bug...
git commit -am "Fix critical bug"
git push
# Back to feature
cd ../feature-auth
Worktree Helper Script:
#!/bin/bash
# scripts/worktree.sh
# ABOUTME: Git worktree management helper
# ABOUTME: Simplifies creating and managing worktrees
set -e
WORKTREE_BASE="${WORKTREE_BASE:-$(dirname $(git rev-parse --git-dir))}"
case "$1" in
add)
BRANCH="$2"
DIR="${3:-$WORKTREE_BASE/../$(echo $BRANCH | tr '/' '-')}"
if git show-ref --verify --quiet "refs/heads/$BRANCH"; then
git worktree add "$DIR" "$BRANCH"
else
git worktree add -b "$BRANCH" "$DIR"
fi
echo "Created worktree at: $DIR"
;;
remove)
git worktree remove "$2"
;;
list)
git worktree list
;;
*)
echo "Usage: $0 {add|remove|list} [branch] [directory]"
exit 1
;;
esac
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
gsd-complete-milestone
Archive completed milestone and prepare for next version
gsd-reapply-patches
Reapply local modifications after a GSD update
gsd-verify-work
Validate built features through conversational UAT
gsd-thread
Manage persistent context threads for cross-session work
clinical-trial-protocol
Generate clinical trial protocols for medical devices or drugs through a modular, waypoint-based architecture with research-only and full protocol modes.
single-cell-rna-qc
Performs quality control on single-cell RNA-seq data (.h5ad or .h5 files) using scverse best practices with MAD-based filtering and comprehensive visualizations.
Didn't find tool you were looking for?