Quick reference for the most common Git commands. Search and copy with one click.
| Command | Description | |
|---|---|---|
git config --global user.name "Name" | Set global username | |
git config --global user.email "email" | Set global email | |
git config --list | List all configuration settings | |
git config --global core.editor "code --wait" | Set VS Code as default editor | |
git config --global alias.st status | Create a git alias |
| Command | Description | |
|---|---|---|
git init | Initialize a new local repository | |
git init <directory> | Initialize in a specific directory | |
git clone <url> | Clone a remote repository | |
git clone <url> <directory> | Clone into a specific folder | |
git clone --depth 1 <url> | Shallow clone (latest snapshot only) |
| Command | Description | |
|---|---|---|
git status | Show working tree status | |
git add <file> | Stage a specific file | |
git add . | Stage all changes | |
git add -p | Interactively stage hunks | |
git commit -m "message" | Commit with a message | |
git commit --amend | Amend the last commit | |
git diff | Show unstaged changes | |
git diff --staged | Show staged changes | |
git rm <file> | Remove a file from tracking | |
git mv <old> <new> | Move or rename a file |
| Command | Description | |
|---|---|---|
git branch | List local branches | |
git branch -a | List all branches (local + remote) | |
git branch <name> | Create a new branch | |
git checkout <branch> | Switch to a branch | |
git checkout -b <branch> | Create and switch to a new branch | |
git switch <branch> | Switch to a branch (modern) | |
git switch -c <branch> | Create and switch (modern) | |
git branch -d <branch> | Delete a merged branch | |
git branch -D <branch> | Force-delete a branch | |
git branch -m <old> <new> | Rename a branch |
| Command | Description | |
|---|---|---|
git merge <branch> | Merge branch into current branch | |
git merge --no-ff <branch> | Merge with a merge commit (no fast-forward) | |
git merge --squash <branch> | Squash all commits into one before merging | |
git merge --abort | Abort an in-progress merge | |
git rebase <branch> | Rebase current branch onto another | |
git rebase -i HEAD~<n> | Interactive rebase last N commits | |
git rebase --abort | Abort an in-progress rebase | |
git cherry-pick <commit> | Apply a specific commit to current branch |
| Command | Description | |
|---|---|---|
git stash | Stash current changes | |
git stash push -m "message" | Stash with a description | |
git stash list | List all stashes | |
git stash pop | Apply and remove the latest stash | |
git stash apply stash@{n} | Apply a specific stash | |
git stash drop stash@{n} | Delete a specific stash | |
git stash clear | Remove all stashes | |
git stash branch <branch> | Create branch from stash |
| Command | Description | |
|---|---|---|
git restore <file> | Discard changes in working directory | |
git restore --staged <file> | Unstage a file | |
git reset HEAD~1 | Undo last commit (keep changes staged) | |
git reset --soft HEAD~1 | Undo last commit (keep changes staged) | |
git reset --hard HEAD~1 | Undo last commit (discard changes) | |
git revert <commit> | Create a new commit that undoes a commit | |
git clean -fd | Remove untracked files and directories | |
git reflog | Show history of HEAD movements |
| Command | Description | |
|---|---|---|
git remote -v | List remotes with URLs | |
git remote add origin <url> | Add a remote named origin | |
git remote remove <name> | Remove a remote | |
git fetch | Fetch all remotes | |
git fetch <remote> | Fetch a specific remote | |
git pull | Fetch and merge from remote | |
git pull --rebase | Fetch and rebase onto remote | |
git push | Push to tracking remote branch | |
git push -u origin <branch> | Push and set upstream | |
git push --force-with-lease | Force push (safe version) | |
git push origin --delete <branch> | Delete a remote branch |
| Command | Description | |
|---|---|---|
git log | Show commit history | |
git log --oneline | Compact one-line log | |
git log --oneline --graph --all | Visual branch graph | |
git log -p | Show commits with patches | |
git log --author="name" | Filter by author | |
git log --since="2 weeks ago" | Filter by date | |
git log --grep="keyword" | Search commit messages | |
git diff <branch1>..<branch2> | Diff between two branches | |
git show <commit> | Show a specific commit | |
git blame <file> | Show who changed each line | |
git shortlog -sn | Summarize commits by author |
Yes, Git Cheatsheet is completely free to use on UtilityCove.
No. Git Cheatsheet runs in your browser, so your input stays on your device.
Yes. Git Cheatsheet works on modern mobile and desktop browsers.
Folder Structure Generator
Build folder structure diagrams, ASCII directory trees, and file tree visualizations for READMEs and docs.
.gitignore Generator
Generate merged .gitignore rules for your stack with one click.
JSON to TypeScript Interface
Convert JSON into TypeScript interfaces with inferred nested types.
Text to Slug Converter
Convert titles and phrases into clean SEO-friendly URL slugs.
UTM Builder
Build campaign URLs with UTM parameters for analytics tracking.
JSON Formatter & Validator
Validate, format, and minify JSON directly in your browser.