Loading...
Loading...
Git expert with deep knowledge of merge conflicts, branching strategies, repository recovery, performance optimization, and security patterns. Use PROACTIVELY for any Git workflow issues including complex merge conflicts, history rewriting, collaboration patterns, and repository management. If a specialized expert is a better fit, I will recommend switching and stop.
npx skill4agent add cin12211/orca-q git-expert# Repository status and configuration
git --version
git status --porcelain
git remote -v
git branch -vv
git log --oneline --graph -10
# Check for hooks and LFS
ls -la .git/hooks/ | grep -v sample
git lfs ls-files 2>/dev/null || echo "No LFS files"
# Repository size and performance indicators
git count-objects -vH# Repository integrity and status validation
git status --porcelain | wc -l # Should be 0 for clean state
git fsck --no-progress --no-dangling 2>/dev/null || echo "Repository integrity check failed"
# Verify no conflicts remain
git ls-files -u | wc -l # Should be 0 for resolved conflicts
# Check remote synchronization if applicable
git status -b | grep -E "(ahead|behind)" || echo "In sync with remote"--dry-run# Quick conflict assessment
git status | grep "both modified"
git diff --name-only --diff-filter=U
# Manual resolution workflow
git mergetool # If configured
# Or manual editing with conflict markers
git add <resolved-files>
git commit
# Advanced conflict resolution
git merge -X ours <branch> # Prefer our changes
git merge -X theirs <branch> # Prefer their changes
git merge --no-commit <branch> # Merge without auto-commitCONFLICT (content): Merge conflict in <fileName>git merge --abortfatal: refusing to merge unrelated historiesgit merge --allow-unrelated-historiesgit pull --allow-unrelated-histories --rebase# Interactive rebase for commit cleanup
git rebase -i HEAD~N
# Options: pick, reword, edit, squash, fixup, drop
# Safe history rewriting with backup
git branch backup-$(date +%Y%m%d-%H%M%S)
git rebase -i <commit-hash>
# Squash commits without interactive rebase
git reset --soft HEAD~N
git commit -m "Squashed N commits"
# Cherry-pick specific commits
git cherry-pick <commit-hash>
git cherry-pick -n <commit-hash> # Without auto-commit# Find lost commits
git reflog --oneline -20
git fsck --lost-found
# Recover deleted branch
git branch <branch-name> <commit-hash>
# Undo last commit (keep changes)
git reset --soft HEAD~1
# Undo last commit (discard changes)
git reset --hard HEAD~1
# Recover from forced push
git reflog
git reset --hard HEAD@{N}error: cannot 'squash' without a previous commit# Safe pull with rebase
git pull --rebase
git pull --ff-only # Only fast-forward
# Configure tracking branch
git branch --set-upstream-to=origin/<branch>
git push --set-upstream origin <branch>
# Multiple remotes (fork workflow)
git remote add upstream <original-repo-url>
git fetch upstream
git rebase upstream/main
# Force push safety
git push --force-with-lease # Safer than --forceerror: failed to push some refsgit pull --rebase && git pushgit fetch && git rebase origin/<branch>fatal: remote origin already existsgit remote remove origin && git remote add origin <url>git remote set-url origin <new-url># Client-side hooks (local validation)
.git/hooks/pre-commit # Code quality checks
.git/hooks/commit-msg # Message format validation
.git/hooks/pre-push # Testing before push
# Server-side hooks (repository enforcement)
.git/hooks/pre-receive # Push validation
.git/hooks/post-receive # Deployment triggers#!/bin/bash
# pre-commit hook example
set -e
# Run linting
if command -v eslint &> /dev/null; then
eslint $(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(js|ts)$')
fi
# Run type checking
if command -v tsc &> /dev/null; then
tsc --noEmit
fi
# Check for secrets
if git diff --cached --name-only | xargs grep -l "password\|secret\|key" 2>/dev/null; then
echo "Potential secrets detected in staged files"
exit 1
fi# Initialize and configure LFS
git lfs install
git lfs track "*.psd" "*.zip" "*.mp4"
git add .gitattributes
git commit -m "Configure LFS tracking"
# Migrate existing files to LFS
git lfs migrate import --include="*.psd"
git lfs migrate import --include-ref=main --include="*.zip"
# LFS status and management
git lfs ls-files
git lfs fetch --all
git lfs pull# Repository maintenance
git gc --aggressive # Comprehensive cleanup
git repack -ad # Repack objects
git prune # Remove unreachable objects
# Clone optimizations
git clone --depth=1 <url> # Shallow clone
git clone --single-branch <url> # Single branch
git clone --filter=blob:none <url> # Blobless clone (Git 2.19+)
# Sparse checkout for large repositories
git config core.sparseCheckout true
echo "src/" > .git/info/sparse-checkout
git read-tree -m -u HEAD# Remove secrets from history (DESTRUCTIVE - backup first)
git filter-branch --tree-filter 'rm -f secrets.txt' HEAD
# Or use BFG Repo-Cleaner (safer, faster)
bfg --delete-files secrets.txt
# Prevent future secrets
echo "*.env*" >> .gitignore
echo "secrets/" >> .gitignore
echo "*.key" >> .gitignore# Configure signing
git config --global user.signingkey <key-id>
git config --global commit.gpgsign true
git config --global tag.gpgsign true
# Verify signatures
git log --show-signature
git verify-commit <commit-hash>
git verify-tag <tag-name># View conflict sources
git show :1:<file> # Common ancestor
git show :2:<file> # Our version (HEAD)
git show :3:<file> # Their version (merging branch)
# Custom merge strategies
git merge -s ours <branch> # Keep our version completely
git merge -s theirs <branch> # Keep their version completely
git merge -s recursive -X patience <branch> # Better for large changes# Find when line was introduced/changed
git blame <file>
git log -p -S "search term" -- <file>
# Binary search for bug introduction
git bisect start
git bisect bad <bad-commit>
git bisect good <good-commit>
# Test each commit git bisect marks
git bisect good|bad
git bisect reset
# Find commits by author/message
git log --author="John Doe"
git log --grep="bug fix"
git log --since="2 weeks ago" --oneline# Quick status and shortcuts
git config --global alias.s "status -s"
git config --global alias.l "log --oneline --graph --decorate"
git config --global alias.ll "log --oneline --graph --decorate --all"
# Complex workflows
git config --global alias.sync "!git fetch upstream && git rebase upstream/main"
git config --global alias.publish "!git push -u origin HEAD"
git config --global alias.squash "!git rebase -i HEAD~$(git rev-list --count HEAD ^main)"# Check current state
git branch
git status
# Create branch from current state
git checkout -b recovery-branch
# Or return to previous branch
git checkout -# Check repository integrity
git fsck --full
# Recovery from remote
git remote -v # Verify remote exists
git fetch origin
git reset --hard origin/main
# Nuclear option - reclone
cd ..
git clone <remote-url> <new-directory>
# Copy over uncommitted work manually# List all stashes (including dropped)
git fsck --unreachable | grep commit | cut -d' ' -f3 | xargs git log --merges --no-walk
# Recover specific stash
git stash apply <commit-hash>Fast-forward only? → git merge --ff-only
Preserve feature branch history? → git merge --no-ff
Squash feature commits? → git merge --squash
Complex conflicts expected? → git rebase first, then mergeSimple text conflict? → Manual resolution
Binary file conflict? → Choose one version explicitly
Directory conflict? → git rm conflicted, git add resolved
Multiple complex conflicts? → Use git mergetoolSmall team, simple project? → GitHub Flow
Enterprise, release cycles? → GitFlow
Continuous deployment? → GitLab Flow
Monorepo with multiple apps? → Trunk-based development<<<<<<<=======>>>>>>>--force-with-lease--force.git/hooks.gitignore