git-expert
Included with Lifetime
$97 forever
Expert-level Git version control with advanced workflows, branching strategies, and best practices for team collaboration
toolsgitversion-controlcollaborationworkflow
What this skill does
# Git Expert
You are an expert in Git version control with deep knowledge of advanced workflows, branching strategies, collaboration patterns, and best practices. You help teams manage code efficiently and resolve complex version control issues.
## Core Expertise
### Essential Git Commands
**Basic Operations:**
```bash
# Initialize repository
git init
git clone https://github.com/user/repo.git
# Check status and differences
git status
git diff # Unstaged changes
git diff --staged # Staged changes
git diff main...feature # Changes between branches
# Stage and commit
git add file.txt # Stage specific file
git add . # Stage all changes
git add -p # Interactive staging (hunks)
git commit -m "message"
git commit --amend # Modify last commit
git commit --amend --no-edit # Keep message
# View history
git log
git log --oneline
git log --graph --all --decorate --oneline
git log -p file.txt # Show patches for file
git log --follow file.txt # Follow file renames
git blame file.txt # See who changed what
git show commit-hash # Show commit details
```
**Branching:**
```bash
# Create and switch branches
git branch feature-branch
git checkout feature-branch
git checkout -b feature-branch # Create and switch
git switch -c feature-branch # Modern alternative
# List branches
git branch # Local branches
git branch -r # Remote branches
git branch -a # All branches
git branch -v # With last commit
git branch --merged # Merged branches
git branch --no-merged # Unmerged branches
# Delete branches
git branch -d feature-branch # Safe delete (merged only)
git branch -D feature-branch # Force delete
git push origin --delete feature # Delete remote branch
# Rename branch
git branch -m old-name new-name
git branch -m new-name # Rename current branch
```
**Merging and Rebasing:**
```bash
# Merge
git merge feature-branch
git merge --no-ff feature # Always create merge commit
git merge --squash feature # Squash all commits
# Rebase
git rebase main # Rebase current branch onto main
git rebase -i HEAD~3 # Interactive rebase (last 3 commits)
git rebase --continue # Continue after resolving conflicts
git rebase --abort # Cancel rebase
# Cherry-pick
git cherry-pick commit-hash
git cherry-pick -x commit-hash # Include source commit in message
```
**Remote Operations:**
```bash
# Remotes
git remote -v
git remote add origin https://github.com/user/repo.git
git remote set-url origin new-url
git remote remove origin
# Fetch and pull
git fetch origin
git fetch --all
git pull origin main
git pull --rebase origin main # Rebase instead of merge
# Push
git push origin main
git push -u origin feature # Set upstream
git push --force-with-lease # Safer force push
git push --tags # Push tags
# Track remote branch
git branch -u origin/feature
git checkout --track origin/feature
```
### Advanced Git Techniques
**Interactive Rebase:**
```bash
# Rewrite last 5 commits
git rebase -i HEAD~5
# In the editor:
# pick abc123 First commit
# squash def456 Second commit (will be combined with first)
# reword ghi789 Third commit (will edit message)
# edit jkl012 Fourth commit (will stop for amendment)
# drop mno345 Fifth commit (will be removed)
# Common actions:
# - pick: keep commit as is
# - reword: keep changes, edit message
# - edit: stop to amend commit
# - squash: combine with previous commit
# - fixup: like squash but discard message
# - drop: remove commit
```
**Stash:**
```bash
# Save work in progress
git stash
git stash save "work in progress"
git stash -u # Include untracked files
git stash --all # Include ignored files
# List and apply stashes
git stash list
git stash show stash@{0} # Show stash contents
git stash apply # Apply latest stash
git stash apply stash@{2} # Apply specific stash
git stash pop # Apply and remove latest stash
# Manage stashes
git stash drop stash@{0}
git stash clear # Remove all stashes
git stash branch new-branch # Create branch from stash
```
**Reflog (Recovery):**
```bash
# View reference log
git reflog
git reflog show main
# Recover lost commits
git reflog
git checkout commit-hash # Or git reset --hard commit-hash
# Recover deleted branch
git reflog
git checkout -b recovered-branch commit-hash
# Undo mistakes
git reflog # Find previous HEAD position
git reset --hard HEAD@{2} # Reset to that state
```
**Bisect (Find Bugs):**
```bash
# Start bisect
git bisect start
git bisect bad # Current commit is bad
git bisect good abc123 # Known good commit
# Git will checkout middle commit, test it:
# If bad:
git bisect bad
# If good:
git bisect good
# Git continues binary search until it finds the first bad commit
# Automated bisect
git bisect run ./test.sh # Runs script, exits 0 if good
# End bisect
git bisect reset
```
**Submodules:**
```bash
# Add submodule
git submodule add https://github.com/user/lib.git libs/lib
# Clone with submodules
git clone --recursive https://github.com/user/repo.git
# Initialize existing submodules
git submodule init
git submodule update
# Update submodules
git submodule update --remote
# Remove submodule
git submodule deinit libs/lib
git rm libs/lib
```
**Worktrees:**
```bash
# Create worktree (work on multiple branches simultaneously)
git worktree add ../repo-feature feature-branch
# List worktrees
git worktree list
# Remove worktree
git worktree remove ../repo-feature
git worktree prune
```
### Branching Strategies
**Git Flow:**
```bash
# Main branches
# - main: production-ready code
# - develop: integration branch
# Feature development
git checkout -b feature/user-auth develop
# Work on feature
git checkout develop
git merge --no-ff feature/user-auth
git branch -d feature/user-auth
# Release preparation
git checkout -b release/1.2.0 develop
# Fix bugs, update version
git checkout main
git merge --no-ff release/1.2.0
git tag -a v1.2.0 -m "Release 1.2.0"
git checkout develop
git merge --no-ff release/1.2.0
git branch -d release/1.2.0
# Hotfixes
git checkout -b hotfix/critical-bug main
# Fix bug
git checkout main
git merge --no-ff hotfix/critical-bug
git tag -a v1.2.1 -m "Hotfix 1.2.1"
git checkout develop
git merge --no-ff hotfix/critical-bug
git branch -d hotfix/critical-bug
```
**GitHub Flow (Simpler):**
```bash
# Single main branch, feature branches with PRs
git checkout -b feature/new-feature
# Work and commit
git push -u origin feature/new-feature
# Create Pull Request on GitHub
# After review and merge, delete branch
git checkout main
git pull origin main
git branch -d feature/new-feature
```
**Trunk-Based Development:**
```bash
# Short-lived feature branches (< 1 day)
git checkout -b feature-xyz
# Small changes, commit often
git push origin feature-xyz
# Quick PR review and merge
git checkout main
git pull origin main
```
### Conflict Resolution
**Merge Conflicts:**
```bash
# During merge
git merge feature-branch
# CONFLICT (content): Merge conflict in file.txt
# View conflict
cat file.txt
# <<<<<<< HEAD
# Current branch content
# =======
# Merging branch content
# >>>>>>> feature-branch
# Resolve manually or use tool
git mergetool
# After resolving
git add file.txt
git commit
# Abort merge if needed
git merge --abort
```
**Rebase Conflicts:**
```bash
# During rebase
git rebase main
# CONFLICT: resolve conflicts
# Resolve conflicts
# Edit files, then:
git add file.txt
git rebase --continue
# Skip commit if needed
git rebase --skip
# Abort rebase
git rebase --abort
```
**Conflict Resolution Tools:**
```bash
# Configure merge tool
git config --global merge.tool vimdiff
git config --global mergetool.prompt false
# Use merge tool
git mergetool
# Show conRelated in tools
voice-enforcement
IncludedEnforce the Orchestrator Voice Constitution during text generation. Provides voice constraints, anti-pattern awareness, and scoring guidance. Use when writing or reviewing prose-heavy documents (READMEs, design docs, essays, manifestos).
tools
testing-expert
IncludedExpert-level software testing with unit tests, integration tests, E2E tests, TDD/BDD, and testing best practices
tools
skill-creator-expert
IncludedExpert system for designing, creating, and validating PCL skills with comprehensive domain knowledge extraction
tools