Searchable reference of common Git commands, organized by category.
Create an empty Git repository.
git initClone a repository into a new directory.
git clone Show the working tree status.
git statusAdd file contents to the index.
git add Add all current changes to the index.
git add .Record changes to the repository.
git commit -m ""List, create, or delete branches.
git branchCreate a new branch.
git branch Switch branches.
git checkout Create and switch to a new branch.
git checkout -b Join two development histories together.
git merge Delete a local branch.
git branch -d Manage set of tracked repositories.
git remote add Show URLs of remote repositories.
git remote -vUpdate remote refs.
git push Fetch and integrate with another repository.
git pull Stash changes in a dirty working directory.
git stashList stash entries.
git stash listRestore modified files from the latest stash.
git stash applyApply and remove the latest stash.
git stash popDiscard changes in working directory.
git checkout -- Remove a file from the staging area.
git reset HEAD Undo the last commit, keep changes staged.
git reset --soft HEAD~1Undo the last commit and discard changes.
git reset --hard HEAD~1Reapply commits interactively.
git rebase -i HEAD~Apply changes from an existing commit.
git cherry-pick Show commit logs, one line per commit.
git log --onelineDelete stale remote-tracking branches.
git remote prune originCreate a lightweight tag.
git tag Create an annotated tag with a message.
git tag -a -m ""List all tags.
git tagPush a single tag to a remote.
git push Delete a local tag.
git tag -d Create a new working tree checked out to a branch.
git worktree add List all working trees.
git worktree listRemove a working tree.
git worktree remove Clean up stale worktree admin files.
git worktree pruneBegin a binary search for the commit that introduced a bug.
git bisect startMark a commit as containing the bug.
git bisect bad Mark a commit as not containing the bug.
git bisect good End the bisect session and return to the original HEAD.
git bisect resetAdd a new submodule.
git submodule add Initialize submodules recorded in .gitmodules.
git submodule initFetch and check out submodule contents recursively.
git submodule update --init --recursiveClone a repository along with its submodules.
git clone --recurse-submodules Show a log of where HEAD has been.
git reflogCheck out a commit found via reflog to recover lost work.
git checkout Reset the branch to a specific reflog entry.
git reset --hard HEAD@{}