AgentSheet
Back
πŸ“¦

Git

vcscliworkflow

Setup & Config

CommandDescription
git config --global user.name "Name"Set username
git config --global user.email "email@example.com"Set email
git config --listList all config

Basic Workflow

CommandDescription
git initInitialize repo
git add <file> / git add .Stage files
git commit -m "msg"Commit staged
git statusWorking tree status
git logView commit history

Branching

CommandDescription
git branchList branches
git branch <name>Create branch
git checkout <branch>Switch branch
git switch <branch>Switch (modern)
git merge <branch>Merge into current
git rebase <branch>Rebase onto branch

Remote Operations

CommandDescription
git remote -vList remotes
git remote add origin <url>Add remote
git fetchFetch remote refs
git pullFetch + merge
git pushPush to remote
git clone <url>Clone repo

Stashing

git stash              # Stash changes
git stash list         # List stashes
git stash pop          # Apply & remove most recent
git stash apply        # Apply, keep stash
git stash drop         # Remove stash

Undoing Changes

CommandDescription
git reset --soft HEAD~1Undo commit, keep changes staged
git reset --mixed HEAD~1Undo commit, unstage changes
git reset --hard HEAD~1Undo commit, discard changes
git revert <commit>New commit that undoes
git checkout -- <file>Discard file changes
git restore <file>Restore file (modern)

Tagging

git tag v1.0.0              # Lightweight tag
git tag -a v1.0.0 -m "msg"  # Annotated tag
git push origin v1.0.0      # Push tag

Log & Diff

CommandDescription
git log --onelineCompact one-line log
git log -pLog with patches
git log --graphGraph view
git diffUnstaged changes
git diff --stagedStaged changes
git diff <commit>Diff vs commit

Advanced

CommandDescription
git cherry-pick <commit>Apply single commit
git bisect startStart bisect search
git bisect good/badMark bisect state
git reflogReference log (recovery)