Explore Git Commands
Each command is an animated lesson, and each option a short demo — or an explanation when it cannot be shown honestly.
72 commands · 275 options
✦ Setup & Creating Projects
git init
Turn a folder into a Git repository
Create an empty Git repository
git clone
Download a project from GitHub
Copy a repository into a new folder
git config
Read and change Git settings
Get and set Git settings
git version
Which Git is installed
Show the installed Git version
git help
Find the right command
Show help for Git and its commands
git bugreport
Collect information for a Git bug report
git diagnose
Collect diagnostics about the repository in a zip file
◐ Basic Snapshotting
git add
PopularStage changes for the next commit
Add file contents to the index (staging area)
git commit
PopularSave a snapshot of what is staged
Record changes to the repository
git reset
Undo commits by moving the branch back
Reset current HEAD to the specified state
git status
See what changed and what is staged
Show the state of your working files and staging area
git diff
See the exact lines you changed
Show changes between your files, the staging area and commits
git restore
Undo changes to a file
Restore files in the working tree or the staging area
git rm
Delete a file and stage the deletion
Remove files from the working tree and the staging area
git mv
Rename or move a file
Move or rename a file
git clean
Delete untracked files
Remove untracked files from the working tree
git revert
Undo a commit safely with a new commit
Undo a commit by creating a new commit
⑂ Branching & Merging
git branch
Create and list branches
List, create, or delete branches
git merge
Combine another branch into yours
Join two or more development histories together
git checkout
PopularSwitch to another branch
Switch branches or restore working tree files
git rebase
AdvancedReplay your commits onto a newer base
Reapply commits on top of another base tip
git stash
Park unfinished work to switch tasks
Stash the changes in a dirty working directory away
git cherry-pick
AdvancedCopy one commit onto your branch
Apply changes from specific commits onto the current branch
git switch
Move between branches
Switch branches
git tag
Name a commit, e.g. a release
Create, list and delete tags
☁ Sharing and Updating
git push
PopularUpload your commits to origin
Update remote refs along with associated objects
git pull
PopularGet your teammates’ commits
Fetch from and integrate with another repository or a local branch
git fetch
Download new commits without merging
Download objects and refs from another repository
git remote
See and add the servers you sync with
Manage the remote repositories you sync with
◎ Inspection & Comparison
git log
PopularRead the commit history
Show commit logs
git show
Look inside one commit
Show a commit, a tag or a file at a given version
git reflog
Find commits you lost
Show where HEAD and branches have been
git describe
Name a commit after the nearest tag
Give a commit a readable name based on the nearest tag
git shortlog
Summarize commits by author
Summarize the history by author
git show-branch
Compare branches side by side
Show branches and which commits each one contains
git whatchanged
History with the files each commit changed
Show logs with the files each commit changed (legacy)
git notes
Attach a note to a commit without changing it
Attach notes to commits without changing them
git verify-commit
Check the GPG signature of commits
git verify-tag
Check the GPG signature of tags
⌕ Debugging
git blame
Who changed each line, and when
Show who last changed each line of a file
git annotate
Blame in the old tab-separated format
Annotate file lines with commit information (older blame format)
git grep
Search text in tracked files
Search for text in tracked files
git bisect
Find the commit that introduced a bug
Find the commit that introduced a bug by binary search
✎ Patching & Rewriting
git format-patch
Turn commits into patch files
Turn commits into email-ready patch files
git am
Apply patch files as commits
Apply patches from email files as commits
git range-diff
Compare two versions of a branch
Compare two versions of a series of commits
git merge-tree
Test a merge without touching anything
Compute a merge without touching the working tree
git rerere
Reuse a recorded conflict resolution
Reuse recorded conflict resolutions
git filter-branch
Rewrite history with filters (deprecated — use git filter-repo)
git replace
Replace an object with another one, without rewriting history
git history
Rewrite commits with simple subcommands (experimental)
▦ Workspaces & Large Projects
git worktree
Work on two branches at once
Check out several branches at once in separate folders
git sparse-checkout
Check out only some folders
Check out only some folders of a large repository
git submodule
Include other repositories inside your repository
git backfill
Download missing file contents in a partial clone
⚙ Administration
git archive
Export a version as a zip or tar file
Export the files of a commit as a zip or tar archive
git bundle
Move a repository as a single file
Pack commits and branches into a single file
git fsck
Check the repository and find lost commits
Verify the repository and find unreachable objects
git fast-export
Dump the history as a text stream
Export history as a fast-import text stream
git fast-import
Build a repository from a fast-import stream
git gc
Clean up and optimize the repository
git maintenance
Run or schedule background repository maintenance
git repack
Pack loose objects into packfiles
git pack-refs
Pack references into a single file
git prune
Delete unreachable objects
git count-objects
Count objects and show how much disk space they use
git refs
Low-level access to the reference storage
git instaweb
Browse the repository in a web browser
⧉ External Tools
git mergetool
Resolve merge conflicts with a visual tool
git difftool
Show changes in a visual diff tool
git gui
Open the graphical interface that ships with Git
git citool
Make one commit with the graphical commit tool