maclin
← Zurück zur Übersicht

Git & GitHub

Versionskontrolle, Branches, Commits und Remote-Repositories

Setup & Konfiguration

Mac & Linux
git init

Erstellt ein neues Git-Repository

Mac & Linux
git clone <url>

Klont ein Remote-Repository

Mac & Linux
git config --global user.name 'Name'

Setzt den globalen Benutzernamen

Grundlegende Befehle

Mac & Linux
git status

Zeigt den Status des Repositories

Mac & Linux
git add .

Fügt alle Änderungen zum Staging hinzu

Mac & Linux
git commit -m 'Nachricht'

Erstellt einen Commit mit Nachricht

Mac & Linux
git diff

Zeigt unstaged Änderungen

Mac & Linux
git log --oneline

Zeigt Commit-Historie kompakt

Branches

Mac & Linux
git branch

Listet alle lokalen Branches

Mac & Linux
git branch <name>

Erstellt einen neuen Branch

Mac & Linux
git checkout <branch>

Wechselt zu einem Branch

Mac & Linux
git checkout -b <name>

Erstellt und wechselt zu neuem Branch

Mac & Linux
git merge <branch>

Merged einen Branch in den aktuellen

Remote-Repositories

Mac & Linux
git remote add origin <url>

Fügt ein Remote-Repository hinzu

Mac & Linux
git push origin main

Pusht Commits zum Remote-Repository

Mac & Linux
git pull origin main

Holt und merged Änderungen vom Remote

Mac & Linux
git fetch origin

Holt Änderungen ohne zu mergen

Rückgängig machen

Mac & Linux
git reset HEAD <datei>

Entfernt Datei aus dem Staging

Mac & Linux
git checkout -- <datei>

Verwirft lokale Änderungen einer Datei

Mac & Linux
git stash

Speichert Änderungen temporär zwischen

Mac & Linux
git stash pop

Wendet gestashte Änderungen wieder an