Git
Essential version control commands for branching, committing, merging, and managing your codebase history with confidence.
169 commands
Browse by Topic
Getting Started
Quick setup and installation
Basics
Basic git commands
Commits
Commit operations
Branches
Branch management
Stash
Stash operations
Rebase
Rebase operations
Remote
Remote repository operations
History
History and logs
Reflog
Reference log recovery
Bisect
Binary search for bugs
Worktree
Multiple working trees
Submodules
Submodule management
Tags
Tag management
Cleanup
Cleanup operations
Config
Git configuration
Maintenance
Repository maintenance
Sparse Checkout
Partial repository checkout
Advanced
Advanced git operations
Install Git (macOS)
Install Git using Homebrew on macOS
Configure user name
Set your name for Git commits globally
Configure user email
Set your email for Git commits globally
Initialize repository
Create a new Git repository in the current directory
Initialize repository
Create a new Git repository in the current directory.
Clone repository
Clone a remote repository to your local machine.
Clone with depth
Shallow clone with only the latest commit for faster downloads.
Clone specific branch
Clone a specific branch.
Status
Show working tree status.
Short status
Show status in short format.
Add all changes
Stage all changes for commit.
Add specific file
Stage specific file for commit.
Add interactively
Interactively stage hunks of changes.
Commit
Commit staged changes with message.
Commit all tracked changes
Stage and commit all tracked files.
Pull
Fetch and merge from remote.
Pull with rebase
Fetch and rebase local commits on top.
Push
Push commits to remote.
Fetch all
Fetch from all remotes.
Undo last commit (keep changes)
Undo last commit but keep changes staged.
Undo last commit (unstage changes)
Undo last commit and unstage changes.
Undo last commit (discard changes)
Completely remove last commit and changes.
Amend last commit message
Change message of last commit.
Amend without changing message
Add staged changes to last commit.
Cherry-pick commit
Apply a specific commit from another branch.
Cherry-pick without commit
Apply changes without committing.
Cherry-pick range
Apply a range of commits.
View file at commit
Display file contents at specific commit.
Revert commit
Create new commit that undoes changes.
Commit with signature
Create GPG-signed commit.
Empty commit
Create commit with no changes.
Fixup commit
Create fixup commit for autosquash.
Stash changes
Stash uncommitted changes.
Stash with message
Stash with descriptive message.
Stash including untracked
Stash including untracked files.
Stash specific files
Stash only specific files.
List stashes
Show all stashed changes.
Show stash contents
Show diff of stash contents.
Apply stash
Apply latest stash, keep in list.
Apply specific stash
Apply specific stash by index.
Pop stash
Apply and remove latest stash.
Drop stash
Remove specific stash.
Clear all stashes
Remove all stashes.
Create branch from stash
Create branch and apply stash.
Rebase onto branch
Rebase current branch onto another.
Interactive rebase
Interactively rewrite last 5 commits.
Interactive rebase from root
Rebase entire history from first commit.
Rebase with autosquash
Auto-reorder fixup/squash commits.
Continue rebase
Continue after resolving conflicts.
Abort rebase
Cancel rebase and restore state.
Skip commit during rebase
Skip current commit and continue.
Rebase onto specific commit
Transplant commits to new base.
List remotes
Show remote repositories with URLs.
Add remote
Add a new remote repository.
Remove remote
Remove a remote.
Rename remote
Rename a remote.
Change remote URL
Update remote repository URL.
Push with upstream
Push and set upstream tracking.
Force push safely
Force push, abort if remote changed.
Delete remote branch
Delete branch from remote.
Prune remote branches
Remove stale remote tracking branches.
Fetch and prune
Fetch and remove deleted branches.
Push tags
Push all tags to remote.
Sync fork with upstream
Update fork with upstream changes.
View reflog
Show reference log (all HEAD changes).
Reflog for branch
Show reflog for specific branch.
Recover deleted branch
Restore branch from reflog entry.
Recover lost commit
Recover commit from reflog.
Reset to reflog entry
Reset to previous HEAD state.
Start bisect
Begin binary search for bug.
Mark bad commit
Mark current commit as bad.
Mark good commit
Mark commit as good.
Reset bisect
End bisect and return to original HEAD.
Bisect with script
Automate bisect with test script.
Skip bisect commit
Skip untestable commit.
List worktrees
Show all linked working trees.
Add worktree
Create new working tree for branch.
Add worktree with new branch
Create worktree with new branch.
Remove worktree
Remove a linked working tree.
Prune worktrees
Clean up stale worktree information.
Lock worktree
Prevent worktree from being removed.
Unlock worktree
Allow worktree to be removed.
Move worktree
Move worktree to new location.
Add submodule
Add a git submodule.
Initialize submodules
Initialize submodule configuration.
Update submodules
Clone and checkout submodules.
Update submodules to latest
Update submodules to latest remote.
List submodules
Show submodule status.
Clone with submodules
Clone repo including submodules.
Remove submodule
Remove a submodule.
Execute in all submodules
Run command in each submodule.
List tags
List all tags.
Create lightweight tag
Create a simple tag.
Create annotated tag
Create tag with message.
Create signed tag
Create GPG-signed tag.
Tag specific commit
Tag a specific commit.
Delete local tag
Remove a local tag.
Delete remote tag
Remove tag from remote.
Push single tag
Push specific tag to remote.
Checkout tag
Checkout a specific tag.
Clean dry run
Preview files to be removed.
Clean untracked files
Remove untracked files and directories.
Clean including ignored
Remove untracked and ignored files.
Discard file changes
Discard changes to a file.
Restore file (modern)
Discard changes (Git 2.23+).
Unstage file
Unstage a file.
Reset to commit
Reset HEAD, index, and working tree.
Garbage collect
Optimize repository storage.
Set user name
Set global git username.
Set user email
Set global git email.
Set default editor
Set default text editor.
Set default branch
Set default branch for new repos.
Enable autostash on rebase
Auto-stash before rebase.
Set pull to rebase
Default pull to rebase instead of merge.
List all config
Show all git configuration.
Create alias
Create git command alias.
Set GPG signing key
Configure GPG key for signing.
Enable auto signing
Auto-sign all commits with GPG.
Start background maintenance
Enable automatic background maintenance.
Stop background maintenance
Disable automatic background maintenance.
Run maintenance tasks
Manually run repository maintenance tasks.
Register for maintenance
Register repo for background maintenance.
Unregister from maintenance
Unregister repo from background maintenance.
Optimize repository pack
Aggressive repository optimization and compression.
Prune unreachable objects
Remove unreachable objects from database.
Initialize sparse checkout
Enable sparse checkout mode.
Set sparse checkout paths
Define which paths to include in checkout.
Add sparse checkout paths
Add additional paths to sparse checkout.
List sparse checkout patterns
Show current sparse checkout patterns.
Reapply sparse checkout
Reapply sparse checkout rules to working tree.
Disable sparse checkout
Disable sparse checkout and populate all files.
Switch to detached HEAD
Switch to commit in detached HEAD state.
Restore from specific commit
Restore file from specific commit.
Compare commit ranges
Compare two commit ranges for rebasing.
Create bundle file
Create bundle file for offline transport.
Discussion
Loading comments...