This skill provides comprehensive guidance on diagnosing and resolving git issues, recovering from mistakes, fixing corrupted repositories, and handling common error scenarios.
Confirm successful installation by checking the skill directory location:
.cursor/skills/git-troubleshooting
Restart Cursor to activate git-troubleshooting. Access via /git-troubleshooting in your agent's command palette.
β
Security Notice
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your environment. Always review source, verify the publisher, and test in isolation before production.
This skill provides comprehensive guidance on diagnosing and resolving git issues, recovering from mistakes, fixing corrupted repositories, and handling common error scenarios.
When to Use
Activate this skill when:
Encountering git error messages
Recovering lost commits or branches
Fixing corrupted repositories
Resolving detached HEAD state
Handling botched merges or rebases
Diagnosing repository issues
Recovering from force push
Fixing authentication problems
Recovering Lost Commits
Using Reflog
# View reflog (local history of HEAD)git reflog
# View reflog for specific branchgit reflog show branch-name
# Output example:# abc123 HEAD@{0}: commit: feat: add authentication# def456 HEAD@{1}: commit: fix: resolve bug# ghi789 HEAD@{2}: reset: moving to HEAD~1# Recover lost commitgit cherry-pick abc123
# Or create branch from lost commitgit branch recovered-branch abc123
# Or reset to lost commitgit reset --hard abc123
# Find branch commit in refloggit reflog
# Look for branch deletion:# abc123 HEAD@{5}: checkout: moving from feature-branch to main# Recreate branchgit branch feature-branch abc123
# Or if branch was merged before deletiongit log --all--oneline|grep"feature"git branch feature-branch def456
Recovering After Reset
# After accidental reset --hardgit reflog
# Find commit before reset:# abc123 HEAD@{0}: reset: moving to HEAD~5# def456 HEAD@{1}: commit: last good commit# Restore to previous stategit reset --hard def456
# Or create recovery branchgit branch recovery def456
Resolving Detached HEAD
Understanding Detached HEAD
# Detached HEAD state occurs when:git checkout abc123
git checkout v1.0.0
git checkout origin/main
# HEAD is not attached to any branch
Recovering from Detached HEAD
# Check current stategit status
# HEAD detached at abc123# Option 1: Create new branchgit checkout -b new-branch-name
# Option 2: Return to previous branchgit checkout main
# Option 3: Reattach HEAD to branchgit checkout -b temp-branch
git checkout main
git merge temp-branch
# If you made commits in detached HEAD:git reflog
# Find the commitsgit branch recovery-branch abc123
Preventing Detached HEAD
# Instead of checking out tag directlygit checkout -b release-v1.0 v1.0.0
# Instead of checking out remote branchgit checkout -b local-feature origin/feature-branch
# Check if HEAD is detachedgit symbolic-ref -q HEAD &&echo"attached"||echo"detached"
Fixing Merge Conflicts
Understanding Conflict Markers
<<<<<<< HEAD (Current Change)
int result = add(a, b);
||||||| merged common ancestors (Base)
int result = sum(a, b);
=======
int sum = calculate(a, b);
>>>>>>> feature-branch (Incoming Change)
# Abort mergegit merge --abort# Abort rebasegit rebase --abort# Abort cherry-pickgit cherry-pick --abort# Abort revertgit revert --abort# Abort am (apply mailbox)git am --abort
Complex Conflict Resolution
# Use merge toolgit mergetool
# View three-way diffgitdiff--oursgitdiff--theirsgitdiff--base# Show conflicts with contextgitdiff--check# List conflicted filesgitdiff --name-only --diff-filter=U
# After resolving all conflictsgitadd.git commit
Fixing Botched Rebase
Recovering from Failed Rebase
# Abort current rebasegit rebase --abort# Find state before rebasegit reflog
# abc123 HEAD@{1}: rebase: checkout main# Return to pre-rebase stategit reset --hard HEAD@{1}# Alternative: use ORIG_HEADgit reset --hard ORIG_HEAD
Rebase Conflicts
# During rebase conflictgit status
# both modified: file.go# Resolve conflicts# Edit file.gogitadd file.go
git rebase --continue# Skip problematic commitgit rebase --skip# Edit commit during rebasegit commit --amendgit rebase --continue
Rebase onto Wrong Branch
# Find original branch pointgit reflog
# Reset to before rebasegit reset --hard HEAD@{5}# Rebase onto correct branchgit rebase correct-branch
βΊAccess to product documentation and roadmap tools (Jira, Notion, etc.)
βΊUnderstanding of product management frameworks (RICE, Jobs-to-be-Done, etc.)
βΊStakeholder contact information and communication channels
Time Estimate
30-60 minutes to see productivity improvements
Steps
1Install product management skill
2Start with user story generation for known feature
3Progress to competitive analysis: research 2-3 competitors
4Use for roadmap prioritization: apply RICE/ICE scoring
5Draft stakeholder communications and refine based on feedback
6Build template library for recurring PM tasks
7Share effective prompts with product team
Common Pitfalls
β Not validating competitive researchβverify facts before sharing
β Accepting user stories without involving engineering team
β Over-relying on frameworks without qualitative judgment
β Not customizing outputs to company culture and communication style
β Skipping stakeholder validation of generated requirements
Best Practices
β Do
+Validate research and competitive analysis with real data
+Collaborate with engineering when generating technical requirements
+Customize frameworks and templates to your company context
+Use skill for first drafts, refine with stakeholder input
+Document successful prompt patterns for PM tasks
+Combine AI efficiency with human judgment and intuition
β Don't
βDon't publish competitive analysis without fact-checking
βDon't finalize user stories without engineering review
βDon't make prioritization decisions solely on AI scoring
βDon't skip customer validation of generated requirements
βDon't ignore company-specific context and culture
π‘ Pro Tips
β Provide context: company goals, constraints, customer feedback
β Ask for alternatives: 'Show 3 ways to prioritize this roadmap'
β Request stakeholder-specific formatting: 'Executive summary vs. engineering spec'
β Use skill for 70% generation + 30% customization to company needs
When to Use This
β Use when
Use for user story writing, competitive research, roadmap prioritization, stakeholder communication, and PRD drafting. Best for reducing repetitive documentation and research work.
β Avoid when
Avoid for strategic product vision (requires deep customer empathy), pricing decisions (needs market and financial expertise), or when face-to-face customer discovery is more valuable than speed.
Learning Path
1Basic: user stories, feature specs, status updates