Skip to main content

Git Cheat Sheet 2026 — Quick CLI Command Reference

Git Cheat Sheet 2026 — Quick Command Reference

Git Cheat Sheet is the complete quick-reference of Git commands grouped by function. Copy any command with one click and find what you need with Ctrl+F in under 3 seconds.

Staging & Status

Action Command Useful flags
Create an empty Git repository
git init
Clone a remote Git repository from the internet
git clone <https://example.com/repo.git>
View the status of the local repository
git status
Stage all changes for a commit
git add --all
--all
Commit changes to version history
git commit --message <message_text>
--message
Push local commits to a remote repository
git push
Pull any changes made to a remote
git pull
Reset everything the way it was in the latest commit
git reset --hard; git clean --force
--hard --force

Commits

Action Command Useful flags
Open an editor to write a message and commit staged files to the repository
git commit
Commit staged files to the repository with the specified message
git commit --message "<message>"
--message
Commit staged files with a message read from a file
git commit --file <path/to/commit_message_file>
--file
Auto stage all modified and deleted files and commit
git commit --all --message "<message>"
--all --message
Commit staged files and sign them with the specified GPG key (or the one defined
git commit --gpg-sign <key_id> --message "<message>"
--gpg-sign --message
Update the last commit by adding the currently staged changes, changing the comm
git commit --amend
--amend
Commit only specific (already staged) files
git commit <path/to/file1 path/to/file2 ...>
Create a commit with the specified message and description
git commit --message "<message>" --message "<description>"
--message

Branches

Action Command Useful flags
List all branches (local and remote; the current branch is highlighted by `*`)
git branch --all
--all
List which branches include a specific Git commit in their history
git branch --all --contains <commit_hash>
--all --contains
Show the name of the current branch
git branch --show-current
--show-current
Create new branch based on the current commit
git branch <branch_name>
Create new branch based on a specific commit
git branch <branch_name> <commit_hash>
Rename a branch (you must switch to a different branch before doing this)
git branch --move <old_branch_name> <new_branch_name>
--move
Delete a local branch (you must switch to a different branch before doing this)
git branch --delete <branch_name>
--delete
Delete a remote branch
git push <remote_name> --delete <remote_branch_name>
--delete

Remotes & Sync

Action Command Useful flags
List existing remotes with their names and URLs
git remote --verbose
--verbose
Show information about a remote
git remote show <remote_name>
Add a remote
git remote add <remote_name> <remote_url>
Change the URL of a remote (use `–add` to keep the existing URL)
git remote set-url <remote_name> <new_url>
Show the URL of a remote
git remote get-url <remote_name>
Remove a remote
git remote remove <remote_name>
Rename a remote
git remote rename <old_name> <new_name>

Stash

Action Command Useful flags
Stash the current uncommitted changes
git stash
Stash current changes, including new untracked files
git stash --include-untracked
--include-untracked
Interactively select parts of changed files for stashing
git stash --patch
--patch
List all stashes
git stash list
Show the changes as a patch between the stash and the commit back when stash ent
git stash show --patch
--patch
Apply a stash and remove it from the stash list if applying doesn’t cause confli
git stash pop
Delete the latest stash
git stash drop
Delete all stashes
git stash clear

Rebase & History

Action Command Useful flags
Rebase the current branch on top of another specified branch
git rebase <new_base_branch>
Start an interactive rebase, which allows the commits to be reordered, omitted,
git rebase --interactive <target_base_branch_or_commit_hash>
--interactive
Continue a rebase that was interrupted by a merge failure, after editing conflic
git rebase --continue
--continue
Continue a rebase that was paused due to merge conflicts, by skipping the confli
git rebase --skip
--skip
Abort a rebase in progress (e.g. if it is interrupted by a merge conflict)
git rebase --abort
--abort
Move part of the current branch onto a new base, providing the old base to start
git rebase --onto <new_base> <old_base>
--onto
Reapply the last 5 commits in-place, stopping to allow them to be reordered, omi
git rebase --interactive <HEAD~5>
--interactive
Auto-resolve any conflicts by favoring the working branch version (`theirs` keyw
git rebase --strategy-option theirs <branch_name>
--strategy-option
Show the sequence of commits starting from the current one, in reverse chronolog
git log
Show the history of a particular file or directory, including differences
git log --patch <path/to/file_or_directory>
--patch
Show an overview of which file(s) changed in each commit
git log --stat
--stat
Show a graph of commits in the current branch using only the first line of each
git log --oneline --graph
--oneline --graph

⚠️ Dangerous / Destructive Commands

These commands are irreversible. Verify your environment (dev/staging vs prod) before running them.

Action Command Warning
⚠️ Delete
git branch --delete <branch_name>
Irreversible — verify the target before running
⚠️ Push
git push <remote_name> --delete <remote_branch_name>
Irreversible — verify the target before running
⚠️ Stash drop
git stash drop
Irreversible — verify the target before running

FAQ — Frequently Asked Questions

What is the difference between Staging & Status and Commits?

Each group in this Git cheat sheet covers a distinct area. Staging & Status focuses on its specific scope, while Commits and the remaining groups cover networking, storage, security and diagnostics respectively.

How do I check the installed Git version?

Run the version command (usually git version or git --version). The output shows the client and, when applicable, the server version.

Why does Git return ‘permission denied’?

A ‘permission denied’ error in Git usually means the current user lacks sufficient privileges or credentials are not configured. Check: (1) assigned IAM/RBAC roles, (2) an active authentication context via the corresponding login command.

How do I filter Git output by status or name?

Use flags such as --filter, --selector or --query depending on the tool. You can also pipe into grep or jq to process JSON:

git list | grep RUNNING

What is the fastest way to debug a Git error?

Add the verbose flag (--verbose, -v or --debug) to the failing command. This reveals the underlying HTTP/API calls and the full error response body.

Official sources & references

Commands cross-checked against vendor documentation and high-authority repositories: