⚡
usefultools.dev
git

Git-Spickzettel

NEU

Git-Spickzettel mit den täglich genutzten Befehlen: commit, branch, switch, restore, merge, rebase, stash, reset und mehr. Mit Suchfilter und Kopieren per Klick. Die Befehle sind auf Englisch.

Läuft zu 100 % in deinem Browser — deine Eingaben werden nie hochgeladen oder auf unseren Servern gespeichert.

96 Einträge in 12 Abschnitten

Setup

Run once per machine.

  • git --version

    Show the installed Git version.

  • git config --global user.name "Your Name"

    Set the author name used on your commits.

  • git config --global user.email "[email protected]"

    Set the author email used on your commits.

  • git config --global init.defaultBranch main

    Name the first branch of new repositories "main".

  • git config --list --show-origin

    List every setting and the file it comes from.

Create & clone

  • git init

    Turn the current folder into a new repository.

  • git clone <url>

    Copy a remote repository into a new folder.

  • git clone --depth 1 <url>

    Clone only the latest commit (shallow clone, much faster).

  • git clone -b <branch> <url>

    Clone and check out a specific branch.

  • git clone --recurse-submodules <url>

    Clone and also fetch submodules.

Stage & commit

  • git status

    Show changed, staged and untracked files.

  • git status -sb

    Short status with the branch name.

  • git add <file>

    Stage one file.

  • git add .

    Stage all changes in the current folder and below.

  • git add -p

    Choose which hunks of each file to stage, one by one.

  • git commit -m "message"

    Commit the staged changes with a message.

  • git commit -am "message"

    Stage all tracked, modified files and commit (new files are not included).

  • git commit --amend

    Change the last commit: its message and/or the staged content.

  • git commit --amend --no-edit

    Add staged changes to the last commit and keep its message.

  • git rm <file>

    Delete a file and stage the deletion.

  • git mv <old> <new>

    Rename or move a file and stage the change.

Branches

  • git branch

    List local branches.

  • git branch -a

    List local and remote-tracking branches.

  • git branch <name>

    Create a branch without switching to it.

  • git switch <branch>

    Switch to an existing branch.

  • git switch -c <branch>

    Create a branch and switch to it.

  • git checkout <branch>

    Classic way to switch branches.

  • git checkout -b <branch>

    Classic way to create and switch to a branch.

  • git switch -

    Go back to the previous branch.

  • git branch -m <new-name>

    Rename the current branch.

  • git branch -d <branch>

    Delete a branch that is already merged.

  • git branch -D <branch>

    Force-delete a branch, even if unmerged.

  • git restore <file>

    Discard unstaged changes in a file (cannot be undone).

  • git restore --staged <file>

    Unstage a file but keep your edits.

  • git restore --source=<commit> <file>

    Bring back a file as it was in another commit.

Merge & rebase

  • git merge <branch>

    Merge another branch into the current one.

  • git merge --no-ff <branch>

    Always create a merge commit, even if a fast-forward is possible.

  • git merge --squash <branch>

    Apply all changes of a branch as staged changes, without committing.

  • git merge --abort

    Cancel a merge that has conflicts and go back to before it.

  • git rebase <branch>

    Replay the current branch on top of another branch.

  • git rebase -i HEAD~3

    Interactively edit, squash or reorder the last 3 commits.

  • git rebase --continue

    Continue a rebase after resolving conflicts.

  • git rebase --abort

    Stop a rebase and restore the branch as it was.

Remote

  • git remote -v

    List remotes with their URLs.

  • git remote add origin <url>

    Add a remote called origin.

  • git remote set-url origin <url>

    Change the URL of a remote.

  • git fetch

    Download new commits and branches without changing your files.

  • git fetch --prune

    Fetch and drop remote-tracking branches that no longer exist.

  • git pull

    Fetch and merge the upstream branch into the current one.

  • git pull --rebase

    Fetch and rebase your commits on top of the upstream branch.

  • git push

    Upload your commits to the upstream branch.

  • git push -u origin <branch>

    Push a new branch and remember it as the upstream.

  • git push --force-with-lease

    Force-push, but refuse if someone else pushed in the meantime.

  • git push origin --delete <branch>

    Delete a branch on the remote.

Stash

Park unfinished work without committing.

  • git stash

    Stash modified tracked files and clean the working tree.

  • git stash push -u -m "message"

    Stash including untracked files, with a label.

  • git stash list

    List all stashes.

  • git stash pop

    Re-apply the latest stash and remove it from the list.

  • git stash apply stash@{1}

    Re-apply a specific stash and keep it in the list.

  • git stash drop stash@{0}

    Delete one stash.

Undo: reset & revert

  • git reset --soft HEAD~1

    Undo the last commit but keep its changes staged.

  • git reset HEAD~1

    Undo the last commit and keep the changes unstaged (mixed reset).

  • git reset --hard HEAD~1

    Undo the last commit and throw its changes away.

  • git reset --hard origin/main

    Make the local branch identical to the remote one, losing local work.

  • git revert <commit>

    Create a new commit that undoes an earlier commit (safe for shared history).

  • git revert -m 1 <merge-commit>

    Revert a merge commit, treating its first parent as the mainline.

  • git reflog

    Show where HEAD has been, to recover "lost" commits.

Log & diff

  • git log --oneline --graph --decorate

    Compact history with branch graph and ref names.

  • git log -p <file>

    Show the history of a file with the changes in each commit.

  • git log --author="name"

    Only show commits by an author.

  • git log -S"text"

    Find commits that added or removed a string.

  • git show <commit>

    Show one commit with its diff.

  • git diff

    Show unstaged changes.

  • git diff --staged

    Show staged changes that will go into the next commit.

  • git diff main..feature

    Compare the tips of two branches.

  • git blame <file>

    Show who last changed each line of a file.

Tags

  • git tag

    List tags.

  • git tag v1.0.0

    Create a lightweight tag on the current commit.

  • git tag -a v1.0.0 -m "Release 1.0.0"

    Create an annotated tag with a message.

  • git push origin v1.0.0

    Push one tag to the remote.

  • git push --tags

    Push all local tags.

  • git tag -d v1.0.0

    Delete a local tag.

Cherry-pick & bisect

  • git cherry-pick <commit>

    Copy one commit onto the current branch.

  • git cherry-pick A^..B

    Copy a range of commits from A to B (inclusive).

  • git cherry-pick --abort

    Cancel a cherry-pick that hit conflicts.

  • git bisect start

    Begin a binary search for the commit that introduced a bug.

  • git bisect bad

    Mark the current commit as broken.

  • git bisect good <commit>

    Mark a commit where things still worked.

  • git bisect reset

    End the bisect session and return to your branch.

Cleanup, config & aliases

  • git clean -nd

    Dry run: show untracked files and folders that would be removed.

  • git clean -fd

    Delete untracked files and folders (cannot be undone).

  • git gc

    Compress and clean up the repository database.

  • git config --global alias.st "status -sb"

    Create the alias "git st" for a short status.

  • git config --global alias.lg "log --oneline --graph --decorate"

    Create the alias "git lg" for a compact log graph.

  • git config --global pull.rebase true

    Make git pull rebase instead of merge by default.

  • git config --global core.editor "code --wait"

    Use VS Code as the editor for commit messages.

⚡

Schnelle Beispiele

Typische Eingaben und die Ergebnisse, die dieses Tool liefert.

Rückgängig
Letzten Commit rückgängig machen, Änderungen behalten
git reset --soft HEAD~1
Branch
Branch erstellen und wechseln
git switch -c <branch>
Staging
Datei aus der Staging-Area nehmen
git restore --staged <file>
Stash
Letzten Stash erneut anwenden
git stash pop
📖

Überblick

Git ist das Versionskontrollsystem hinter den meisten Softwareprojekten, und sein Befehlssatz ist so groß, dass selbst erfahrene Entwickler regelmäßig nachschlagen. Dieser Git-Spickzettel bündelt die Befehle für den Alltag: Einrichtung, Klonen, Commits, Branches, Merge, Rebase, Remotes, Stash, Rückgängigmachen, Verlauf und Tags.

Er zeigt moderne Befehle wie git switch und git restore neben den klassischen checkout-Formen und weist deutlich auf Befehle hin, die sich nicht zurücknehmen lassen, etwa reset --hard und clean -fd. Tippe im Filter, um die Liste einzugrenzen, und kopiere jeden Befehl mit einem Klick.

Befehle, Optionen und ihre kurzen Beschreibungen werden auf Englisch angezeigt, so wie du sie im Terminal siehst; übersetzt sind nur der Seitentext und die Oberfläche. Die Seite besteht aus reinem Text, lädt schnell und nichts, was du eingibst, wird irgendwohin gesendet.

Warum dieses Tool?

  • Den passenden Git-Befehl in Sekunden finden
  • Moderne switch- und restore-Befehle neben den klassischen Formen
  • Warnhinweise bei zerstörerischen Befehlen
  • Nach Befehl oder Stichwort filtern
  • Jeden Befehl mit einem Klick kopieren
⭐

Funktionen

🔍

Live-Filter

Gib ein Stichwort ein, um nur passende Befehle und Abschnitte zu sehen.

📋

Kopieren pro Befehl

Jede Zeile hat eine Schaltfläche „Kopieren“ für den genauen Befehl.

🌿

Switch und restore

Moderne Befehle für Branches und Dateien stehen neben den älteren checkout-Formen.

↩️

Abschnitt zum Rückgängigmachen

Reset, revert und reflog sind gruppiert, damit du dich von einem Fehler erholen kannst.

🧭

Verlaufswerkzeuge

Log, diff, blame, cherry-pick und bisect, um herauszufinden, was sich geändert hat.

📱

Für Mobilgeräte geeignet

Lange Befehle werden umgebrochen, die Zeilen bleiben auf dem Smartphone lesbar.

🛠️

So funktioniert’s

1

Abschnitt suchen

Scrolle zum gewünschten Thema, etwa Branches oder Undo (die Abschnittstitel sind auf Englisch).

2

Oder den Filter nutzen

Tippe ein Wort wie „stash“ oder „rebase“ in das Feld „Diesen Spickzettel filtern“.

3

Beschreibung lesen

Jeder Befehl hat eine einzeilige Erklärung auf Englisch, was er tut.

4

Kopieren und ausführen

Klicke auf Kopieren, füge den Befehl im Terminal ein und ersetze Platzhalter wie <branch>.

🤔

Häufig gestellte Fragen