Git Command Helper

Visual guide for modern Git workflows. Copy-paste sequences for branching, syncing, and repairing.

Initialize & First Commit

basic

Start a new repository and push to a remote origin.

$git init
$git add .
$git commit -m "initial commit"
$git branch -M main
$git remote add origin <url>
$git push -u origin main

Interactive Rebase (Cleanup)

branching

Squash or edit the last N commits before pushing.

$git rebase -i HEAD~N
$# Replace 'pick' with 'squash' in the editor
$git push --force-with-lease

Undo Last Commit (Keep Files)

repair

Oops! I committed to the wrong branch or need to edit files.

$git reset --soft HEAD~1

Discard All Local Changes

repair

Reset the working directory to the last commit strictly.

$git reset --hard HEAD
$git clean -fd

Sync Fork with Upstream

remote

Update your fork with the latest changes from the original repo.

$git remote add upstream <original-url>
$git fetch upstream
$git checkout main
$git merge upstream/main

Handle with Care

Commands involving --force or reset --hard will permanently overwrite data. Always ensure your workspace is backed up or changes are stashed before executing destructive operations.

How to Use Git Command Helper

  1. 1

    Search or Browse Commands

    Use the search box to find a specific command, or browse by category.

  2. 2

    Copy the Command

    Click the Copy button next to any command to copy it to your clipboard.

  3. 3

    Use in Your Terminal

    Paste the copied command directly into your terminal.

Frequently Asked Questions

What is git rebase vs git merge?
Both integrate changes from one branch into another. Merge creates a merge commit preserving history. Rebase rewrites history for a linear commit graph.
How do I undo the last commit without losing changes?
Use: git reset --soft HEAD~1 — this undoes the commit but keeps your changes staged.