Git Basics
May 21, 2014
Setup
code
git config --global user.name "Your Name"
git config --global user.email "me@domain.com"
git config --global init.defaultBranch main
Repo erstellen
code
git init
git init -b main
Status & Log
code
git status -sb
git log --oneline --graph --decorate --all
Add & Commit
code
git add -A
git commit -m "message"
Tracked files committen:
code
git commit -am "message"
Branches
code
git branch
git switch -c feature-x
git switch main
Remote
code
git remote add origin git@github.com:user/repo.git
git push -u origin main
Undo
code
git restore file.txt # unstaged aendern wegwerfen
git restore --staged file.txt # aus staging entfernen
git revert <commit> # sicher, history bleibt
Tags
code
git tag v1.0.0
git push --tags