Install
openclaw skills install effective-gitIntelligent Git workflow assistant following best practices. Use when user needs help with git commits, analyzing changes, writing commit messages, pushing code, rebasing, merging, or any git operations. Also triggers on quick command prefix 'gq' or 'gq:' for rapid operations like 'gq b:l' (list branches), 'gq b:n name' (create branch), 'gq:s' (status). Automatically analyzes changes, suggests appropriate commit strategies (amend vs new commit), follows project conventions, and ensures safe operations with confirmation for dangerous commands.
openclaw skills install effective-gitSmart Git workflow assistant that helps you commit, push, and manage code changes following best practices.
Quick help: When user asks "gq help", "gq:h", or "git help", run scripts/show_help.sh to display usage guide
Detailed help: When user asks about specific topics:
references/best-practices.mdreferences/conflict-resolution.mdreferences/quick-commands.mdUsage examples:
gq <command> for quick operations (status, branch switching, etc.)When helping with git operations, follow this sequence:
For simple, read-only operations or quick checks, use scripts/git_quick.sh:
When user asks for:
git_quick.sh b:lgit_quick.sh "b->" xxxgit_quick.sh b:n xxxgit_quick.sh sgit_quick.sh lgit_quick.sh "d"
GIT_QUICK_DIFF_TERMINAL is set, opens in new terminal window$PAGER (default: less)git_quick.sh "d:s"See references/quick-commands.md for full command list.
For commits, pushes, merges, and conflict resolution, follow the detailed workflow below:
Run scripts/analyze_changes.sh to understand:
Check if changes should amend the last commit or create a new one:
Use git commit --amend when:
Use git commit -m "message" when:
Before writing commit message:
git log --oneline -10Follow conventions from references/best-practices.md:
Critical constraint: Only push to current branch.
Before pushing:
git branch --show-currentgit log origin/$(git branch --show-current)..HEAD --onelinegit push origin HEADNever use git push --force without explicit user confirmation.
These require user confirmation before execution:
git push --force or git push -fgit reset --hardgit clean -fdgit rebase on shared/public branchesgit branch -D (force delete)Always explain the risk before asking for confirmation.
Critical Principle: When resolving conflicts, the absolute priority is preserving all code. If unable to confidently resolve, you must summarize the issue and feedback to the user. DO NOT perform automatic merges.
Pre-merge/Rebase Snapshot: Before attempting a merge or rebase, save a snapshot of the current state for documentation and safety.
scripts/save_diff.sh
# Also create backup branch
git branch <current-branch>-backup
This creates a git diff document before the merge.
Detect and Analyze Conflicts: If conflicts arise during a merge or rebase:
scripts/analyze_conflicts.sh
This provides detailed three-way diff analysis for each conflicted file.
Deep Conflict Analysis: For complex conflicts where both sides modified the same code:
Analyze the intent:
Compare approaches:
Determine resolution strategy:
Present Analysis to User: When conflicts cannot be resolved automatically, create a structured summary:
references/conflict-resolution.md for detailed templatePost-Resolution Documentation: After conflicts are resolved:
# Generate diff of resolution
git diff --cached > .git/merge-diffs/resolution_$(date +%Y%m%d_%H%M%S).diff
# Show summary
git diff --cached --stat
Verify No Code Loss: After completing merge/rebase:
# Compare with backup branch
git diff <branch>-backup <branch>
# Review carefully for unexpected deletions
Special attention for edge cases:
references/conflict-resolution.md)references/conflict-resolution.md)# Clean up last N commits
git rebase -i HEAD~N
# Rebase feature branch onto main
git checkout feature-branch
git fetch origin
git rebase origin/main
# Standard merge (preserves history)
git merge feature-branch
# Squash merge (single commit)
git merge --squash feature-branch
git stash # Stash current changes
git stash list # List stashes
git stash pop # Apply and remove last stash
git stash apply stash@{0} # Apply specific stash
git cherry-pick <commit-hash>
git restore <file> # Discard working changes
git restore --staged <file> # Unstage file
git reset HEAD~1 # Undo last commit (keep changes)
For rapid git operations, use scripts/git_quick.sh with the gq prefix pattern:
Trigger pattern: When user message starts with gq: or uses git quick command syntax
Common commands:
gq b:l or gq:b:l - List branchesgq b-> <name> - Switch to branchgq b:n <name> - Create new branch from currentgq s - Quick statusgq l - Recent commitsgq d - Show diffUsage in conversation:
scripts/git_quick.sh b:lscripts/git_quick.sh "b->" featurescripts/git_quick.sh s⚠️ Shell quoting rule: Always quote the command argument when calling git_quick.sh to prevent shell misinterpreting special characters. Use git_quick.sh "b->" <branch>, never git_quick.sh b-> <branch> (shell will treat > as redirection).
See references/quick-commands.md for full command list and usage patterns.
Important: Only trigger quick commands when user explicitly uses gq prefix or quick command syntax. Do not auto-trigger for general git questions.