| name | 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
git status -s
git branch -vv
Viewing Changes
git diff
git diff --cached
git diff main..feature
git diff main...feature
git diff -- PATH
git diff --word-diff
git diff --stat
git show COMMIT
git show COMMIT:PATH
Commit History
git log --oneline -20
git log -p -5
git log --oneline --graph --all
git log --stat
git log --author="NAME"
git log --since="2025-01-01" --until="2025-06-01"
git log --grep="fix"
git log -- PATH
git log -S "function_name"
git log --pretty=format:"%h %ad %s (%an)" --date=short
git blame FILE
git blame -L 10,20 FILE
Staging
git add FILE1 FILE2
git add -u
git add -A
git add -p
git reset HEAD FILE
git restore FILE
git restore --source=COMMIT FILE
Committing
git commit -m "message"
git commit -m "subject" -m "body"
git commit -a -m "message"
git commit --amend
git commit --amend --no-edit
git commit --allow-empty -m "trigger build"
Undoing Commits
git revert COMMIT
git revert --no-commit COMMIT
git revert -m 1 MERGE_COMMIT
git reset --soft COMMIT
git reset --mixed COMMIT
git reset --hard COMMIT
Branch Management
git branch
git branch -a
git branch -r
git branch BRANCH
git switch -c BRANCH
git switch BRANCH
git branch -m NEW_NAME
git branch -d BRANCH
git branch -D BRANCH
git push origin --delete BRANCH
git branch --merged
git branch --no-merged
Merging
git merge BRANCH
git merge --no-ff BRANCH
git merge --squash BRANCH
git merge --abort
git add . && git merge --continue
Rebasing
git rebase TARGET
git rebase --onto NEW_BASE OLD_BASE BRANCH
git rebase -i HEAD~N
git rebase --abort
git rebase --continue
git rebase --skip
git rebase -i --autosquash TARGET
Interactive rebase commands: pick, reword, edit, squash, fixup, drop.
Remote Operations
git remote -v
git remote add NAME URL
git remote remove NAME
git remote rename OLD NEW
git remote set-url origin NEW_URL
git fetch origin
git fetch --all
git fetch --prune
git pull
git pull --rebase
git push origin BRANCH
git push -u origin BRANCH
git push --tags
git push --force-with-lease origin BRANCH
Stash
git stash
git stash push -m "description"
git stash push -m "msg" -- FILE1 FILE2
git stash -u
git stash list
git stash apply stash@{0}
git stash pop
git stash show -p stash@{0}
git stash drop stash@{1}
git stash clear
git stash branch BRANCH stash@{0}
Tags
git tag
git tag -l "v1.*"
git tag -a TAG -m "message"
git tag -a TAG COMMIT -m "message"
git push origin TAG
git push --tags
git tag -d TAG
git push origin --delete TAG
Cherry-Pick
git cherry-pick COMMIT
git cherry-pick --no-commit COMMIT
git cherry-pick START..END
git cherry-pick --abort
git cherry-pick --continue
Bisect (Finding Regressions)
git bisect start
git bisect bad
git bisect good COMMIT
git bisect reset
git bisect start HEAD GOOD_COMMIT
git bisect run ./test-script.sh
Test script exits: 0 = good, 1-124/126-127 = bad, 125 = skip.
Reflog (Recovery)
git reflog
git reflog
git switch -c recovery-branch LOST_HASH
git reset --hard HEAD@{N}
Entries expire after 90 days (30 days for unreachable commits).
Worktree
git worktree add ../path BRANCH
git worktree add -b NEW_BRANCH ../path BASE
git worktree list
git worktree remove ../path
git worktree prune
Submodules
git submodule add URL PATH
git submodule init && git submodule update
git clone --recurse-submodules URL
git submodule update --remote
git submodule deinit PATH && git rm PATH
Conflict Resolution
When a merge, rebase, or cherry-pick encounters conflicts:
git status
git add FILE
git merge --continue
git merge --abort
Patch Creation
git format-patch -N
git format-patch main..feature --stdout > changes.patch
git am < changes.patch
git apply changes.patch
git apply --check changes.patch
Cleanup
git clean -n
git clean -fd
git clean -fdx
git gc
git fsck
Common Workflows
Feature branch
git switch main && git pull
git switch -c feat/my-feature
git add -A && git commit -m "add feature"
git push -u origin feat/my-feature
git switch main && git pull && git branch -d feat/my-feature
Sync feature branch with main
git fetch origin main
git rebase origin/main
Squash commits before PR
git rebase -i HEAD~N