Git Commands Reference
Learn Git commands through practical examples and real-world workflows. Each guide focuses on when to use the command and how it fits into your development process.
Essential Daily Commands
The most frequently used Git commands for daily development work.
git add
Stage changes to include in your next commit, controlling exactly what gets saved to your repository history.
git branch
Create, list, rename, and delete branches to organize parallel lines of development and manage features in your Git repository.
git checkout
Switch between branches, restore working tree files, or explore specific commits in your Git repository with checkout.
git commit
Save your staged changes to the repository history with a descriptive commit message explaining what you changed and why.
git diff
See exactly what changed in your files, comparing between commits, branches, or your working directory and staging area.
git log
View and filter the history of commits in your repository, showing who changed what, when, and why with powerful formatting options.
git merge
Combine changes from different branches, integrating feature work into main or incorporating updates from teammates.
git pull
Fetch changes from a remote repository and automatically merge or rebase them into your current branch to stay up to date.
git push
Upload your local commits to a remote repository, sharing your work with teammates and triggering CI pipelines.
git status
Check which files have been modified, what is staged for commit, and view the current state of your working directory and branch.
Collaboration & PR Workflow
Commands for collaborating with teammates and managing pull request workflows.
git cherry-pick
Apply specific commits from one branch to another, selectively incorporating changes without merging everything.
git clone
Create a local copy of a remote Git repository, downloading all commits, branches, and files so you can start working on the project.
git fetch
Download commits, branches, and tags from a remote repository without automatically merging them into your work.
git rebase
Reapply your commits on top of another branch to create a clean, linear history without merge commits for easier code review.
git remote
Manage named connections to remote repositories, controlling where you push, fetch, and pull code from across multiple origins.
git reset
Move the current branch pointer to a different commit, unstaging files or undoing commits depending on the mode.
git show
Display detailed information about commits, tags, or other Git objects, showing the exact diff and metadata of what changed.
git stash
Temporarily save uncommitted changes to a stack and restore them later, letting you switch branches with a clean working directory.
Advanced Workflow Commands
Advanced commands for complex Git operations and debugging.
git bisect
Use binary search through commit history to efficiently find which commit introduced a bug or regression in your codebase.
git blame
Show which commit and author last modified each line of a file, helping you track down when and why specific changes were made.
git clean
Remove untracked files and directories from your working directory, cleaning up build artifacts and temporary files.
git reflog
View the reference log of where your branch pointers have been, helping you recover lost commits and undo mistakes like bad rebases.
git revert
Safely undo one or more commits by creating new commits that reverse their changes, preserving the full project history.
git tag
Create, list, and manage tags to mark specific commits as important milestones like releases or version numbers in your repository.
git worktree
Work on multiple branches simultaneously by creating additional working directories linked to the same repository.
Specialized Commands
Specialized commands for specific use cases and configurations.
git config
Configure Git settings at global, repository, or system level to customize your workflow, identity, and default behaviors.
git grep
Search for text patterns across tracked files in your repository, faster and more Git-aware than regular grep.
git mv
Move or rename files and directories while preserving their full Git history, keeping the index updated with the relocation.
git rm
Remove files from both your working directory and Git tracking, or stop tracking files while keeping them on disk with the cached option.
git submodule
Include other Git repositories within your repository, managing external dependencies with specific versions.
