git-advanced-workflows

Master advanced Git workflows including rebasing, cherry-picking, bisect, worktrees, and reflog to maintain clean history and recover from any situation. Use when managing complex Git histories, collaborating on feature branches, or troubleshooting repository issues.

Author

Install

Hot:2

Download and extract to your skills directory

Copy command and send to OpenClaw for auto-install:

Download and install this skill https://openskills.cc/api/download?slug=sickn33-skills-git-advanced-workflows&locale=en&source=copy

Git Advanced Workflows - Complete Guide to Advanced Git Workflows

Skills Overview

Master advanced Git techniques, including interactive rebase, cherry-pick, bisect, worktree, and reflog. This helps developers maintain a clean commit history, collaborate more efficiently, and recover from any Git operation mistakes.

When to Use

  • Clean up history before a PR

  • Use interactive rebase to tidy up the commit history before merging—compress typo fixes, rewrite commit messages, and reorder logical commits—so reviewers can understand your changes more easily.

  • Apply specific commits across branches

  • When you need to port a bug fix or feature from a development branch to other branches, use cherry-pick to precisely apply one or consecutive commits, avoiding unnecessary merges.

  • Quickly locate the problematic commit

  • If code has issues but you’re not sure which commit introduced them, use git bisect to quickly find the exact commit that introduced the bug via binary search.

    Core Features

    1. Interactive Rebase

    The Swiss Army knife of editing Git history. Supports six operations—pick (keep), reword (change message), edit (amend), squash (combine), fixup (combine and discard the message), and drop (delete)—giving you full control over your commit history.

    git rebase -i HEAD~5              # Edit the most recent 5 commits
    git rebase -i --autosquash main   # Automatically squash fixup commits

    2. Cherry-Pick and Bisect

    cherry-pick is used to transplant specific commits across branches, supporting single commits, ranges, staging-only modes, and more. bisect uses binary search to quickly pinpoint problematic commits and also supports automation through test scripts.

    git cherry-pick abc123            # Apply a single commit
    git bisect start HEAD v1.0.0      # Search between HEAD and v1.0.0
    git bisect run npm test           # Find using automated tests

    3. Worktree and Reflog

    worktree lets you work on multiple branches in different directories at the same time, without constantly switching or stashing. reflog is your safety net: it records all reference movements within 90 days, allowing you to recover any “lost” commits.

    git worktree add ../project-hotfix hotfix/urgent    # Create an isolated worktree
    git reflog show HEAD                              # View movement history

    Common Questions

    What’s the difference between Git rebase and merge? When should I use each?

    Rebase moves your commits, creating a linear history. It’s suitable for cleaning up local commits that haven’t been pushed and for keeping your branch synchronized with the main branch. Merge preserves the real history structure and is suitable for integrating completed public branches. Key principle: only rebase commits that are local and not yet shared, to avoid affecting collaborators.

    How do I recover a Git commit or branch deleted by mistake?

    Git reflog is the lifesaver—it records all reference changes (including deletions) and keeps them for 90 days. Run git reflog to find the hash of the target commit, then restore it using git branch recovered-branch <hash> or git checkout <hash>. Even after running git reset --hard or deleting a branch, you can still recover it within 90 days.

    Is Git bisect really faster than backing out commits one by one?

    bisect uses a binary search algorithm with time complexity O(log n). Locating a problem among 100 commits takes about 7 test runs, and among 1000 commits takes about 10. Compared to backing out commits one by one, the efficiency improvement is significant. Combined with automated test scripts (git bisect run), it enables unattended searching.

    Skill Boundaries

    This skill focuses on advanced usage of Git branch management and history operations, and does not cover topics such as Git internal mechanisms, submodule management, or sparse checkout. If you need basic clone/push/pull operations, it’s recommended that you first learn Git fundamentals.

    Target Audience

  • Intermediate-to-advanced developers with at least 6 months of Git experience

  • Team members who need to maintain large projects with complex branch structures

  • Developers who want to improve Git efficiency and reduce the risk of losing work due to mistakes

  • Engineers who frequently handle PR reviews, hotfixes, and version releases