Skill v1.0.0
currentAutomated scan100/100name: git category: dev description: > Run git version control commands for repository management. Use when the user asks to check status, view history or diffs, stage and commit changes, manage branches, merge or rebase, work with remotes, stash changes, tag releases, cherry-pick commits, bisect regressions, resolve conflicts, manage worktrees or submodules, or perform any source control operation. Keywords: git, commit, branch, merge, rebase, diff, log, push, pull, stash, tag, remote, conflict. license: MIT compatibility: Requires git (v2.30+) metadata: author: zeph version: "1.0"
Git Operations
Status and Information
git status # working tree statusgit status -s # short formatgit branch -vv # branches with tracking info
Viewing Changes
# Unstaged / staged / between branchesgit diffgit diff --cachedgit diff main..feature# Changes since common ancestor (useful for PRs)git diff main...feature# Diff specific filegit diff -- PATH# Word-level diffgit diff --word-diff# Stat summarygit diff --stat# Show a specific commitgit show COMMIT# Show file at specific commitgit show COMMIT:PATH
Commit History
# Recent commits (compact)git log --oneline -20# With diffsgit log -p -5# Graph viewgit log --oneline --graph --all# With file statsgit log --stat# Filter by author / date / message / filegit log --author="NAME"git log --since="2025-01-01" --until="2025-06-01"git log --grep="fix"git log -- PATH# Commits that added/removed a string (pickaxe)git log -S "function_name"# Custom formatgit log --pretty=format:"%h %ad %s (%an)" --date=short# Who changed each linegit blame FILEgit blame -L 10,20 FILE
Staging
# Stage specific filesgit add FILE1 FILE2# Stage all tracked file changesgit add -u# Stage everything (tracked + untracked)git add -A# Stage hunks interactivelygit add -p# Unstage file (keep changes)git reset HEAD FILE# Discard unstaged changesgit restore FILE# Restore file from specific commitgit restore --source=COMMIT FILE
Committing
# Commit with messagegit commit -m "message"# Multi-line messagegit commit -m "subject" -m "body"# Stage tracked files and commitgit commit -a -m "message"# Amend last commitgit commit --amend# Amend without changing messagegit commit --amend --no-edit# Empty commit (trigger CI)git commit --allow-empty -m "trigger build"
Undoing Commits
# Revert a commit (creates new inverse commit)git revert COMMIT# Revert without auto-commitgit revert --no-commit COMMIT# Revert a merge commit (keep first parent)git revert -m 1 MERGE_COMMIT# Reset to commit (keep changes staged)git reset --soft COMMIT# Reset to commit (keep changes unstaged)git reset --mixed COMMIT# Reset to commit (discard all changes)git reset --hard COMMIT
Branch Management
# List local / all / remote branchesgit branchgit branch -agit branch -r# Create branchgit branch BRANCH# Create and switchgit switch -c BRANCH# Switch branchgit switch BRANCH# Rename current branchgit branch -m NEW_NAME# Delete merged / force delete unmergedgit branch -d BRANCHgit branch -D BRANCH# Delete remote branchgit push origin --delete BRANCH# List merged / unmerged branchesgit branch --mergedgit branch --no-merged
Merging
# Merge branch into currentgit merge BRANCH# Always create merge commitgit merge --no-ff BRANCH# Squash merge (no merge commit, changes staged)git merge --squash BRANCH# Abort / continuegit merge --abortgit add . && git merge --continue
Rebasing
# Rebase current branch onto targetgit rebase TARGET# Rebase onto specific basegit rebase --onto NEW_BASE OLD_BASE BRANCH# Interactive rebase (last N commits)git rebase -i HEAD~N# Abort / continue / skipgit rebase --abortgit rebase --continuegit rebase --skip# Autosquash fixup!/squash! commitsgit rebase -i --autosquash TARGET
Interactive rebase commands: pick, reword, edit, squash, fixup, drop.
Remote Operations
# List remotesgit remote -v# Add / remove / rename remotegit remote add NAME URLgit remote remove NAMEgit remote rename OLD NEW# Change remote URLgit remote set-url origin NEW_URL# Fetch (does not merge)git fetch origingit fetch --allgit fetch --prune # prune deleted remote branches# Pull (fetch + merge)git pullgit pull --rebase # rebase instead of merge# Pushgit push origin BRANCHgit push -u origin BRANCH # set upstreamgit push --tags # push all tags# Safer force push (rejects if remote has unknown commits)git push --force-with-lease origin BRANCH
Stash
# Stash working changesgit stashgit stash push -m "description"# Stash specific filesgit stash push -m "msg" -- FILE1 FILE2# Include untracked filesgit stash -u# List / apply / popgit stash listgit stash apply stash@{0}git stash pop# Show stash diffgit stash show -p stash@{0}# Drop / cleargit stash drop stash@{1}git stash clear# Create branch from stashgit stash branch BRANCH stash@{0}
Tags
# List tagsgit taggit tag -l "v1.*"# Create annotated tag (recommended)git tag -a TAG -m "message"# Tag specific commitgit tag -a TAG COMMIT -m "message"# Push tag / all tagsgit push origin TAGgit push --tags# Delete local / remote taggit tag -d TAGgit push origin --delete TAG
Cherry-Pick
# Apply a commit to current branchgit cherry-pick COMMIT# Without committinggit cherry-pick --no-commit COMMIT# Range of commits (exclusive start)git cherry-pick START..END# Abort / continuegit cherry-pick --abortgit cherry-pick --continue
Bisect (Finding Regressions)
# Manual bisectgit bisect startgit bisect bad # current commit is badgit bisect good COMMIT # known good commit# Git checks out middle commit — test and mark good/bad, repeatgit bisect reset # finish# Automated bisect with test scriptgit bisect start HEAD GOOD_COMMITgit bisect run ./test-script.sh
Test script exits: 0 = good, 1-124/126-127 = bad, 125 = skip.
Reflog (Recovery)
# Show HEAD movement historygit reflog# Recover lost commitgit refloggit switch -c recovery-branch LOST_HASH# Undo accidental resetgit reset --hard HEAD@{N}
Entries expire after 90 days (30 days for unreachable commits).
Worktree
# Add worktree for existing branchgit worktree add ../path BRANCH# Add worktree with new branchgit worktree add -b NEW_BRANCH ../path BASE# List / remove / prunegit worktree listgit worktree remove ../pathgit worktree prune
Submodules
# Add submodulegit submodule add URL PATH# Initialize after clonegit submodule init && git submodule update# Clone with submodulesgit clone --recurse-submodules URL# Update to latest remotegit submodule update --remote# Remove submodulegit submodule deinit PATH && git rm PATH
Conflict Resolution
When a merge, rebase, or cherry-pick encounters conflicts:
git status # see conflicted files# Edit files, remove conflict markers (<<<<<<< / ======= / >>>>>>>)git add FILE # mark resolvedgit merge --continue # or rebase --continue / cherry-pick --continuegit merge --abort # or rebase --abort to cancel
Patch Creation
# Create patches from commitsgit format-patch -N # last N commitsgit format-patch main..feature --stdout > changes.patch# Apply patchgit am < changes.patchgit apply changes.patch# Check if patch applies cleanlygit apply --check changes.patch
Cleanup
# Remove untracked files (dry run first)git clean -ngit clean -fd # files + directoriesgit clean -fdx # including ignored files# Garbage collectgit gc# Verify integritygit fsck
Common Workflows
Feature branch
git switch main && git pullgit switch -c feat/my-feature# ... make changes ...git add -A && git commit -m "add feature"git push -u origin feat/my-feature# After PR merge:git switch main && git pull && git branch -d feat/my-feature
Sync feature branch with main
git fetch origin maingit rebase origin/main # or: git merge origin/main
Squash commits before PR
git rebase -i HEAD~N# Mark commits as squash/fixup, keep first as pick