| name | git-advanced |
| description | Advanced git operations including rebase, bisect, cherry-pick, and conflict resolution. Use when rebasing branches, debugging with bisect, cherry-picking commits, or resolving complex merge conflicts. |
| allowed-tools | Read, Bash, Grep |
Git Advanced Skill
Purpose
Provide guidance for advanced git operations with safety considerations. This project uses a rebase-first workflow with linear history—understand these patterns to avoid breaking the codebase.
When This Skill Applies
Invoke this skill when:
- Rebasing feature branches onto dev
- Using git bisect to find bugs
- Cherry-picking commits between branches
- Resolving complex merge conflicts
- Recovering from git mistakes
Stop-the-Line Conditions
FORBIDDEN Operations
git push --force origin dev
git push --force origin master
git merge feature-branch
git commit --no-verify
git rebase -i HEAD~5 && git push --force
SAFE Operations
git push --force-with-lease origin {{TICKET_PREFIX}}-XXX-feature
git rebase -i origin/dev
git rebase origin/dev && git push --force-with-lease origin {{TICKET_PREFIX}}-XXX-feature
Rebase Workflow (Standard)
Before Creating PR
git fetch origin dev
git rebase origin/dev
git status
git add <resolved-files>
git rebase --continue
git push --force-with-lease origin {{TICKET_PREFIX}}-XXX-feature
During PR Review (After Feedback)
git add . && git commit -m "fix: address PR feedback [{{TICKET_PREFIX}}-XXX]"
git fetch origin dev
git rebase origin/dev
git push --force-with-lease origin {{TICKET_PREFIX}}-XXX-feature
Git Bisect (Finding Bugs)
When to Use
Use bisect when you know a bug was introduced at some point but don't know which commit.
Bisect Workflow
git bisect start
git bisect bad
git bisect good <commit-sha>
yarn test:unit
git bisect good
git bisect bad
git bisect reset
Automated Bisect
git bisect start HEAD abc1234
git bisect run yarn test:specific-test
Cherry-Pick (Selective Commits)
When to Use
- Backporting a fix to an older branch
- Pulling a specific commit from one branch to another
- Selective feature extraction
Cherry-Pick Workflow
git log --oneline branch-name | head -20
git cherry-pick <commit-sha>
git status
git add <resolved-files>
git cherry-pick --continue
git push origin current-branch
Cherry-Pick Multiple Commits
git cherry-pick abc123^..def456
git cherry-pick abc123 def456 ghi789
Conflict Resolution
Common Conflict Scenarios
| Scenario | Resolution Strategy |
|---|
| Same line edited | Choose one version or combine |
| File deleted vs modified | Decide: keep modified or delete |
| Rename conflicts | Decide which name to use |
| Binary file conflicts | Choose one version explicitly |
Conflict Resolution Steps
git status
<<<<<<< HEAD
your changes
=======
their changes
>>>>>>> branch-name
# 3. Edit file to resolve (remove markers, keep correct code)
# 4. Mark as resolved
git add <resolved-file>
# 5. Continue rebase/merge
git rebase --continue
# or
git merge --continue
Conflict Prevention
git fetch origin dev
git rebase origin/dev
git diff origin/dev...HEAD --stat
Recovery Commands
Abort Operations
git rebase --abort
git merge --abort
git cherry-pick --abort
Undo Last Commit
git reset --soft HEAD~1
git reset HEAD~1
git reset --hard HEAD~1
Recover Lost Commits
git reflog
git reset --hard HEAD@{n}
git cherry-pick <sha-from-reflog>
Safety Guidelines
When to Ask Before Force Push
ALWAYS ask first if:
- You've pushed commits that others might have pulled
- You're working on a shared branch
- You're not 100% sure what will happen
- The branch has been open for > 1 week
Safe Force Push Pattern
git branch
git log origin/{{TICKET_PREFIX}}-XXX-feature..HEAD --oneline
git push --force-with-lease origin {{TICKET_PREFIX}}-XXX-feature
Pre-Push Checklist
Related Resources
- CONTRIBUTING.md: Branch naming and commit format
- safe-workflow skill: Complete workflow patterns
- release-patterns skill: PR and merge patterns