⚡ 100% In-Browser & Private: Your data never leaves your computer. Powered by Cloudflare Edge CDN.
ProWebTools PRO
Developer & SEO Utilities
40+ Commands

Git Commands Reference Matrix

The definitive Git command cheat sheet: branching, stashing, rebasing, committing, and undoing mistakes with 1-click copy.

Setup & Configuration (3 commands)

Setup & Configuration
git config --global user.name "Your Name"

Sets the name associated with your commit history globally.

PRO TIP Run once when configuring a new development machine.
Setup & Configuration
git config --global user.email "[email protected]"

Sets the email address attached to your git commits.

PRO TIP Must match your GitHub/GitLab verified email for commit attribution.
Setup & Configuration
git config --global core.defaultBranch main

Sets "main" as the default primary branch for new repositories.

PRO TIP Adheres to modern Git repository naming conventions.

Basic Operations (6 commands)

Basic Operations
git init

Initializes a new, empty Git repository in the current directory.

PRO TIP Creates the hidden .git directory to track file changes.
Basic Operations
git clone <repo-url>

Clones an entire remote repository onto your local disk.

PRO TIP Automatically sets up remote origin tracking to the target URL.
Basic Operations
git status

Displays the state of the working directory and staging area.

PRO TIP Shows modified, staged, untracked, and deleted files.
Basic Operations
git add .

Stages all modified and new files in the repository for the next commit.

PRO TIP Use git add to stage only a single specific file.
Basic Operations
git commit -m "feat: descriptive commit message"

Commits staged changes with a concise commit message.

PRO TIP Follow Conventional Commits (feat:, fix:, docs:, refactor:, chore:).
Basic Operations
git commit --amend --no-edit

Appends staged changes to the most recent commit without changing message.

PRO TIP Great for quickly fixing typos in your last local commit.

Branching & Merging (5 commands)

Branching & Merging
git branch

Lists all local branches in the repository.

PRO TIP The active branch is marked with an asterisk (*).
Branching & Merging
git checkout -b <new-feature-branch>

Creates a new branch and immediately switches to it.

PRO TIP Modern alternative: git switch -c .
Branching & Merging
git switch <branch-name>

Switches to an existing branch cleanly.

PRO TIP Safer and more intuitive than the legacy git checkout.
Branching & Merging
git merge <feature-branch>

Merges the specified branch into your current active branch.

PRO TIP Always git checkout main before merging feature work.
Branching & Merging
git branch -d <branch-name>

Deletes a local branch that has already been merged.

PRO TIP Use -D instead of -d to force delete an unmerged branch.

Remote Sync (3 commands)

Remote Sync
git fetch origin

Downloads commits and branches from the remote repository without merging.

PRO TIP Safest way to check upstream updates without altering working directory.
Remote Sync
git pull origin main --rebase

Fetches and integrates remote changes on top of your local branch linearly.

PRO TIP Avoids messy merge commit bubbles in your git graph.
Remote Sync
git push -u origin <branch-name>

Pushes your local branch to the remote repo and sets upstream tracking.

PRO TIP Subsequent pushes on this branch only require running git push.

Stashing Work (3 commands)

Stashing Work
git stash

Temporarily shelve uncommitted local changes to work on another branch.

PRO TIP Reverts your working directory to clean HEAD.
Stashing Work
git stash pop

Applies the most recently stashed changes and removes them from stash list.

PRO TIP Restores your shelved edits instantly.
Stashing Work
git stash list

Lists all stashed changesets currently preserved.

PRO TIP Shows stash@{0}, stash@{1}, etc.

History & Inspection (3 commands)

History & Inspection
git log --oneline --graph --decorate --all

Displays an ASCII graph of commit history across all branches.

PRO TIP Gives an instant visual overview of project branch topologies.
History & Inspection
git diff

Shows line-by-line differences of unstaged changes in working tree.

PRO TIP Use git diff --staged to review changes about to be committed.
History & Inspection
git blame <file>

Annotates each line in a file with the author, commit hash, and timestamp.

PRO TIP Indispensable for tracking who introduced specific logic lines.

Undoing Mistakes (4 commands)

Undoing Mistakes
git restore <file>

Discards unstaged modifications in the specified file.

PRO TIP Replaces the legacy git checkout -- command.
Undoing Mistakes
git restore --staged <file>

Unstages a file while keeping its modifications in your working folder.

PRO TIP Reverses git add without losing any written code.
Undoing Mistakes
git reset --soft HEAD~1

Undoes the last commit but keeps all changes staged and intact.

PRO TIP Perfect for reorganizing or combining recent commits.
Undoing Mistakes
git revert <commit-hash>

Creates a new commit that exactly inverts the changes of a past commit.

PRO TIP The safe way to undo mistakes on public, shared branches.