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 in your repository.
git checkout
Switch between branches, restore files, or explore specific commits in your Git repository.
git commit
Save your staged changes to the repository history with a message describing what you did 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 the history of commits in your repository, showing who changed what and when.
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 merge them into your current branch in one command.
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 changed, what is staged for commit, and the current state of your working directory.
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 repository, downloading all commits, branches, and files to start working.
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, creating a linear history and cleaner pull requests.
git remote
Manage connections to remote repositories, controlling where you push and fetch code from.
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 exactly what changed.
git stash
Temporarily save uncommitted changes and restore them later, keeping your working directory clean.
Advanced Workflow Commands
Advanced commands for complex Git operations and debugging.
git bisect
Use binary search through commit history to find which commit introduced a bug or regression.
git blame
Show which commit and author last modified each line of a file, tracking down when 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 history of where your branch pointers have been, recovering from mistakes and finding lost commits.
git revert
Safely undo commits by creating new commits that reverse their changes, preserving history.
git tag
Mark specific commits as important milestones like releases or versions in your repository history.
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, customizing behavior and credentials.
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 while preserving history, keeping Git aware of the file relocation.
git rm
Remove files from both your working directory and Git tracking, staging the deletion for commit.
git submodule
Include other Git repositories within your repository, managing external dependencies with specific versions.
