<< All versions
Skill v1.0.1
currentAutomated scan100/1001mangesh1/dev-skills-collection/git-advanced
5 files
──Details
PublishedOctober 25, 2026 at 08:20 PM
Content Hashsha256:b577f207a74ed6f2...
Git SHA23e297e5a4df
Bump Typepatch
──Files
Files (1 file, 5.3 KB)
SKILL.md5.3 KBactive
SKILL.md · 259 lines · 5.3 KB
version: "1.0.1" name: git-advanced description: Advanced Git operations including rebase, cherry-pick, bisect, reflog, and recovery. Use when user asks to "rebase branch", "cherry-pick commit", "find bug with bisect", "recover lost commit", "squash commits", "fix git history", "interactive rebase", or any advanced git tasks.
Git Advanced
Advanced Git operations and recovery techniques.
Interactive Rebase
bash
# Rebase last N commitsgit rebase -i HEAD~5# Rebase onto branchgit rebase -i main# Commands in interactive editor:# pick = keep commit as-is# reword = keep commit, edit message# edit = pause for amending# squash = combine with previous commit# fixup = combine with previous, discard message# drop = remove commit# Squash last 3 commits into onegit rebase -i HEAD~3# Change 'pick' to 'squash' for commits 2 and 3# Abort if something goes wronggit rebase --abort# Continue after resolving conflictsgit rebase --continue# Skip current commitgit rebase --skip
Cherry-Pick
bash
# Pick single commitgit cherry-pick abc1234# Pick range of commitsgit cherry-pick abc1234..def5678# Pick without committing (stage only)git cherry-pick --no-commit abc1234# Pick from another branchgit cherry-pick feature-branch~3 # 3rd commit from tip# Resolve conflicts and continuegit cherry-pick --continue# Abortgit cherry-pick --abort
Bisect
bash
# Start bisectgit bisect start# Mark current as badgit bisect bad# Mark known good commitgit bisect good v1.0.0# Git checks out middle commit - test it, then:git bisect good # If this commit worksgit bisect bad # If this commit is broken# Repeat until Git finds the culprit# End bisectgit bisect reset# Automated bisect with test commandgit bisect start HEAD v1.0.0git bisect run npm test# Git automatically finds the first bad commit# Automated with scriptgit bisect run ./test-script.sh# Script must exit 0 (good) or 1 (bad)
Stash
bash
# Save work in progressgit stashgit stash push -m "work on feature X"# Stash specific filesgit stash push -m "partial" path/to/file.js# Include untracked filesgit stash -ugit stash --include-untracked# List stashesgit stash list# Apply stashgit stash pop # Apply and removegit stash apply # Apply and keepgit stash pop stash@{2} # Specific stash# View stash contentsgit stash show -p stash@{0}# Create branch from stashgit stash branch new-branch stash@{0}# Drop stashgit stash drop stash@{0}git stash clear # Remove all stashes
Reflog (Recovery)
bash
# View refloggit refloggit reflog show HEADgit reflog show main# Each entry shows HEAD position at that point# HEAD@{0} = current# HEAD@{1} = previous position# Recover after hard resetgit reflog# Find the commit hash before the resetgit reset --hard HEAD@{2}# Recover deleted branchgit reflog# Find last commit of deleted branchgit checkout -b recovered-branch abc1234# Recover after bad rebasegit reflog# Find the commit before rebase startedgit reset --hard HEAD@{5}# Reflog expires after 90 days (default)
Reset vs Revert
bash
# Reset (moves HEAD, rewrites history)git reset --soft HEAD~1 # Undo commit, keep changes stagedgit reset --mixed HEAD~1 # Undo commit, keep changes unstaged (default)git reset --hard HEAD~1 # Undo commit, discard changes# Revert (creates new commit, safe for shared branches)git revert abc1234git revert HEAD~3..HEAD # Revert rangegit revert --no-commit abc1234 # Stage without committing# Revert a merge commitgit revert -m 1 abc1234 # Keep parent 1 (usually main)
Worktrees
bash
# Create linked worktreegit worktree add ../project-hotfix hotfix-branchgit worktree add ../project-review origin/feature-branch# List worktreesgit worktree list# Remove worktreegit worktree remove ../project-hotfix# Prune stale worktreesgit worktree prune
Log & History
bash
# Compact loggit log --oneline --graph --all# Search commits by messagegit log --grep="fix bug"# Search commits by code changegit log -S "functionName" # Pickaxe (added/removed)git log -G "pattern" # Regex in diff# Show commits that changed a filegit log --follow -- path/to/file.js# Show who changed each linegit blame path/to/file.jsgit blame -L 10,20 path/to/file.js # Lines 10-20# Diff between branchesgit diff main..featuregit diff main...feature # Changes since fork point# Show files changed between commitsgit diff --name-only HEAD~5 HEAD
Cleanup
bash
# Remove untracked files (dry run first!)git clean -n # Previewgit clean -f # Delete filesgit clean -fd # Delete files and directoriesgit clean -fx # Delete ignored files too# Garbage collectiongit gcgit gc --aggressive# Remove old reflog entriesgit reflog expire --expire=30.days --all
Common Workflows
bash
# Squash merge (clean history)git checkout maingit merge --squash feature-branchgit commit -m "Add feature X"# Rebase before merge (linear history)git checkout featuregit rebase maingit checkout maingit merge feature # Fast-forward# Fixup workflowgit commit --fixup=abc1234git rebase -i --autosquash main
Reference
For recovery techniques and reflog patterns: references/recovery.md