gitinit# Initialize new repo in current dir
gitinitmyproject# Create dir + initialize
gitclonehttps://github.com/org/repo.git# Clone remote repo
gitclone--depth1https://github.com/org/repo.git# Shallow clone (latest only)
gitclone--branchv2.0https://github.com/org/repo.git# Clone specific tag/branch
gitstatus# Working tree status
gitstatus-s# Short format
gitaddfile.py# Stage specific file
gitaddsrc/# Stage directory
gitadd.# Stage all changes
gitadd-p# Stage interactively (hunk by hunk)
gitcommit-m"feat: add user auth"# Commit with message
gitcommit# Open editor for message
gitcommit-am"fix: typo"# Stage tracked + commit (skip add)
gitcommit--amend# Modify last commit (message + files)
gitcommit--amend--no-edit# Add staged files to last commit silently
gitlog# Full log
gitlog--oneline# One line per commit
gitlog--oneline--graph--all# Visual branch graph
gitlog--graph--oneline# Graph for current branch context
gitlog--since="2 weeks ago"# Time-based filter
gitlog--author="Name"# Author filter
gitlog-5# Last 5 commits
gitlog-n10# Last 10 commits
gitlog--path/to/file# History of specific file
gitlog-p--path/to/file# History with diffs
gitshowabc1234# Show specific commit details
gitshowHEAD~3# 3 commits before HEAD
gitdiff# Unstaged changes
gitdiff--staged# Staged changes (ready to commit)
gitdiffHEAD# All changes vs last commit
gitdiffmain..feature# Difference between branches
gitdiff--statmain..feature# Summary (files changed, lines ±)
gitdiff--name-onlymain..feature# Only filenames
gitblamefile.py# Who changed each line
gitblame-L10,20file.py# Blame specific line range
gitremote-v# List remotes with URLs
gitremoteaddoriginhttps://github.com/org/repo.git
gitremoteset-urlorigingit@github.com:org/repo.git
gitfetchorigin# Download changes (no merge)
gitfetch--all# Fetch from all remotes
gitfetch--prune# Fetch + remove stale remote branches
gitpull# Fetch + merge current branch
gitpull--rebase# Fetch + rebase (linear history)
gitpulloriginmain# Pull specific branch
gitpull--rebaseoriginmain# Rebase current branch onto latest origin/main
gitpushoriginfeature/auth# Push branch to remote
gitpush-uoriginfeature/auth# Push + set upstream tracking
gitpush# Push current branch (if upstream set)
gitpush--force-with-leaseoriginfeature/auth# Safer force-push after local history rewrite
gitpush--tags# Push all tags
gitpushorigin--deletefeature/auth# Delete remote branch
gittag# List tags
gittagv1.0.0# Lightweight tag
gittag-av1.0.0-m"Release 1.0.0"# Annotated tag (recommended)
gittag-av1.0.0abc1234-m"Release 1.0.0"# Tag specific commit (message required)
gitpushoriginv1.0.0# Push single tag
gitpushorigin--tags# Push all tags
gittag-dv1.0.0# Delete local tag
gitpushorigin--deleterefs/tags/v1.0.0# Delete remote tag (unambiguous)
gitclean-n# Dry run — show what would be removed
gitclean-fd# Remove untracked files + directories
gitclean-fdx# Also remove ignored files
gitgc# Garbage collect + prune unreachable objects# git prune is called automatically by git gc — don't run it standalone on shared repos