Skill

Master Advanced Git Workflows

Advanced Git skill covering interactive rebase, cherry-picking, bisect, worktrees, and reflog-based recovery from mistakes.

Works with git

79
Spark score
out of 100
Updated last month
Version 13.1.0

Add to Favorites

Why it matters

Elevate your Git proficiency to confidently manage complex codebases, maintain a clean commit history, and recover from any version control mishap.

Outcomes

What it gets done

01

Clean up commit history before merging using interactive rebase.

02

Apply specific commits across branches with cherry-picking.

03

Efficiently find bugs introduced in history with Git Bisect.

04

Manage multiple branches simultaneously with Git Worktrees.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/ag-git-advanced-workflows | bash

Overview

Git Advanced Workflows

An advanced Git skill covering interactive rebase, cherry-picking, bisect, worktrees, and reflog-based recovery, with worked workflows for cleanup, hotfix backporting, and mistake recovery. Use for cleaning commit history, backporting fixes, bisecting regressions, parallel branch work, or recovering from Git mistakes.

What it does

Git Advanced Workflows covers five core techniques for clean history and recovery: interactive rebase (git rebase -i, with pick/reword/edit/squash/fixup/drop operations), cherry-picking specific commits between branches (including ranges and no-commit staging via -n), git bisect for binary-searching the commit that introduced a bug (with an automated git bisect run ./test.sh mode, where the test script must exit 0 for good, 1-127 for bad, except exit code 125 which aborts the bisect), worktrees for working on multiple branches simultaneously without stashing, and reflog as the safety net that tracks all ref movements - including deleted commits - for roughly 90 days.

When to use - and when NOT to

Use it for cleaning up commit history before merging, applying hotfixes across release branches, finding the commit that introduced a regression, working on multiple features simultaneously, recovering from Git mistakes, or preparing a clean PR. Recovering from an accidental git reset --hard:

### Accidentally reset to wrong commit
git reset --hard HEAD~5  # Oh no!

### Use reflog to find lost commits
git reflog
### Output shows:
### abc123 HEAD@{0}: reset: moving to HEAD~5
### def456 HEAD@{1}: commit: my important changes

### Recover lost commits
git reset --hard def456

### Or create branch from lost commit
git branch recovery def456

Inputs and outputs

Five worked practical workflows cover the common cases: cleaning a feature branch before PR (rebase onto main, then git push --force-with-lease), applying a hotfix to multiple release branches via repeated cherry-picks, finding a bug's origin via bisect (manual or scripted against a test command), multi-branch development using worktrees for a hotfix without disrupting the main working directory, and reflog-based recovery from mistakes. Advanced techniques layer on top: choosing rebase (for local cleanup and linear history) versus merge (for preserving collaboration history on public branches), autosquash (git commit --fixup plus git rebase -i --autosquash) to auto-fold fixup commits, splitting one commit into several via edit in an interactive rebase, and partial cherry-picking specific files out of a commit via git checkout <commit> -- <paths>.

Integrations

Best practices: always use --force-with-lease instead of --force, only rebase local/unshared commits, keep commits atomic with descriptive messages, test before force-pushing, and create a backup branch before any risky rebase. Common pitfalls include rebasing public branches (breaks collaborators' history), force-pushing without a lease, losing work mid-rebase, forgetting worktree cleanup (orphaned worktrees waste disk space), and bisecting on a dirty working directory. A recovery command set covers aborting in-progress operations (rebase --abort, merge --abort, cherry-pick --abort, bisect reset), restoring a file from a specific commit, and undoing a commit while keeping or discarding its changes.

Who it's for

Developers who need reliable Git history management and recovery techniques beyond basic add/commit/push - cleaning history before review, backporting fixes across releases, bisecting regressions, and recovering confidently from mistakes via reflog rather than losing work.

FAQ

Common questions

Discussion

Questions & comments ยท 0

Sign In Sign in to leave a comment.