Git-Spickzettel
Setup
git config --global user.name "Name"Set user name
git config --global user.name "Sam"
git config --listShow all config
git config --list
Start
git initInitialize a new repository
git init my-project
git clone <url>Clone a remote repository
git clone https://github.com/user/repo.git
Changes
git statusWorking directory status
git status
git diffCompare changes
git diff HEAD~1
git add <file>Add to staging
git add . / git add file.txt
git commit -m "message"Create a commit
git commit -m "feat: new feature"
git commit --amendAmend the last commit
git commit --amend -m "updated message"
git stashTemporarily stash changes
git stash / git stash pop
Branch
git branchList branches
git branch -a
git branch <name>Create a new branch
git branch feature/login
git checkout <branch>Switch branch
git checkout main
git checkout -b <name>Create and switch
git checkout -b feature/login
git merge <branch>Merge a branch
git merge feature/login
git branch -d <name>Delete a branch
git branch -d feature/login
git branch -D <name>Force-delete a branch
git branch -D feature/login
Remote
git remote -vList remotes
git remote -v
git fetchFetch remote changes
git fetch origin
git pullFetch and merge
git pull origin main
git pushPush to remote
git push origin main
git push --forceForce push
git push --force origin main
Undo
git restore <file>Discard file changes
git restore file.txt
git reset HEAD <file>Unstage a file
git reset HEAD file.txt
git revert <commit>Revert a commit (new commit)
git revert abc123
git reset --soft HEAD~1Undo last commit (keep changes)
git reset --soft HEAD~1
git reset --hard HEAD~1Delete last commit (discard changes)
git reset --hard HEAD~1
Inspect
git logCommit history
git log --oneline --graph
git log --onelineOne-line history
git log --oneline -10
git show <commit>Commit details
git show abc123
git blame <file>Per-line author
git blame file.txt
git reflogHEAD history (for recovery)
git reflog
Was ist Git-Spickzettel?
Kostenlose Git-Cheatsheet mit durchsuchbaren Befehlen nach Kategorie, von Branching und Merging bis Rebase, Stash und Reset, jeweils mit Verwendung und Gefahrenstufe gegen Fehler.
Anleitung
- 1Kategorie wählen— Wählen Sie eine Kategorie wie Konfiguration, Branch oder Rückgängig.
- 2Suchen— Suchen Sie nach Befehl oder Beschreibung.
- 3Gefahrenstufe prüfen— Rote Befehle können Datenverlust verursachen — mit Vorsicht verwenden.
- 4Kopieren— Kopieren Sie den benötigten Befehl und verwenden Sie ihn im Terminal.
Verwandte Tools
Häufig gestellte Fragen
Über 35 Befehle in 7 Kategorien: Konfiguration, Start, Änderungen, Branch, Remote, Rückgängig und Ansicht.
Sicher (grün) bedeutet kein Datenverlust, Vorsicht (gelb) bedeutet Aufmerksamkeit nötig, Gefahr (rot) bedeutet möglicher Datenverlust.
Ja, verwenden Sie die Kopierschaltfläche bei jedem Befehl, um ihn in die Zwischenablage zu kopieren.
Ja, moderne Befehle wie git restore und git switch sind enthalten.
Ja, alle Daten sind statisch enthalten und funktionieren offline.