Git Cheatsheet - Quick Git Command Reference

Quick reference for common Git commands. Search, copy, and use Git commands instantly.

Share

List all configurations

Initialize a new repository

Initialize bare repository

Clone a remote repository

Clone specific branch

Shallow clone (latest commit only)

Clone with submodules

Check working directory status

Short status format

Add file to staging area

Add all changes

Add all changes including deletions

Interactive add (patch mode)

Delete file and stage

Remove file from staging

Commit staged changes

Add and commit all changes

Amend last commit

Amend without changing message

List local branches

List all branches

List remote branches

List merged branches

Create new branch

Force delete branch

Create and switch branch

Switch branch (new)

Create and switch (new)

Merge branch into current

Merge with no fast-forward

Squash merge (no commit)

Rebase onto branch

Interactive rebase last 3 commits

Continue rebase

Abort rebase

Cherry-pick a commit

View remote repositories

Add remote repository

Remove remote repository

Fetch from remote

Fetch and prune remote branches

Pull and merge from remote

Pull with rebase

Push to remote

Push and set upstream

Force push with lease

View commit history

Compact history view

Compact graphical history

Full graphical history

Show change statistics

Show last 3 commits

Filter by author

Filter by commit message

View working directory changes

View staged changes

View all changes

git show <commit>

Show commit details

Show line-by-line author

git shortlog -sn

Author commit count

List all tags

Create lightweight tag

Create annotated tag

Delete local tag

Push tag to remote

Stash current changes

Stash with message

Stash including untracked

List stashes

Show latest stash changes

Pop latest stash

Apply stash without removing

Drop latest stash

Clear all stashes

Create branch from stash

Soft reset to last commit

Mixed reset (default)

Hard reset to last commit

Revert a commit

Discard file changes

Restore file (new)

Unstage file (new)

Preview removing untracked

Remove untracked files and dirs

Init and update submodules

Update submodules recursively

git reflog

View reference log

git reflog show HEAD@{10}

Show specific reference

git gc

Garbage collection

git fsck

Check repository integrity

git archive -o latest.zip HEAD

Export repository as archive

git bundle create repo.bundle --all

Create repository bundle

git bundle unbundle repo.bundle

Unbundle repository

git notes add -m "note" <commit>

Add commit note

git filter-branch --force --index-filter

Rewrite history (use with caution)

Default to rebase on pull

Enable reuse recorded resolution

git check-ignore -v <file>

Check which rule ignores file

git ls-files

List tracked files

git ls-files --others --exclude-standard

List untracked files

Create fixup commit

Create squash commit

Unset upstream tracking

Edit branch description

git merge-base <branch1> <branch2>

Find common ancestor

Delete remote branch (old syntax)

Push with following tags

git whatchanged

Show what changed per commit

git diff-tree --no-commit-id --name-only -r <commit>

Show commit changed files

Save stash (old syntax)

Create stash without storing

Store specific hash as stash

Revert last commit

Revert recent commit range

git update-index --assume-unchanged <file>

Assume file unchanged

git update-index --no-assume-unchanged <file>

Cancel assume unchanged

git update-index --skip-worktree <file>

Skip worktree check

List worktrees

Clone mirror repository

Clone single branch only

Dry run add operation

Force add ignored file

Remove from staging

Amend without changing message

Allow empty commit

Show diff in commit message

Show branch verbose info

Find branches containing commit

Show unmerged branches

Continue merge

Show remote details

Commits since 2 weeks ago

Filter by author

Search code changes

File history with diff

Create annotated tag

Create branch from stash

Clear all stashes

Soft reset last commit

Mixed reset (default)

Discard file changes

Run command on all submodules

Sync submodule URLs

git shortlog -sn

Commit summary by author

git describe --tags

Describe nearest tag

Abort cherry-pick

Continue cherry-pick

Start bisect

Mark current as bad

Mark commit as good

194 of 194 commands shown

Related Tools

More Code & Dev Tools