Git kann viel mehr als add, commit, push. Hier sind 15 Befehle, die Sie vom Anwender zum Power User machen.
1. git stash¶
git stash push -m “WIP: login form” git stash list git stash pop git stash apply stash@{2}
2. git log –oneline –graph¶
git log –oneline –graph –all –decorate
3. git bisect — Binäre Bug-Suche¶
git bisect start git bisect bad git bisect good v1.0.0
15 Git-Befehle, die jeder Entwickler kennen sollte¶
git bisect reset
4. git rebase -i¶
git rebase -i HEAD~5
pick, squash, reword, edit, drop, fixup¶
5. git cherry-pick¶
git cherry-pick abc1234
6. git reflog — Sicherheitsnetz¶
git reflog git checkout HEAD@{5}
7. git blame¶
git blame -L 10,20 src/app.py git blame -w # ignoriert Whitespace
8. git diff –staged¶
git diff –staged git diff –stat
9. git commit –amend¶
git commit –amend -m “bessere Beschreibung” git commit –amend –no-edit
10. git clean¶
git clean -fd git clean -fdn # Trockenlauf
11. git worktree¶
git worktree add ../hotfix hotfix-branch
12. git shortlog¶
git shortlog -sn –since=”1 month ago”
13. git tag¶
git tag -a v1.0.0 -m “Release 1.0” git push origin –tags
14. git reset¶
git reset –soft HEAD~1 # behält Änderungen staged git reset –mixed HEAD~1 # Änderungen unstaged git reset –hard HEAD~1 # löscht alles
15. Aliase¶
git config –global alias.co checkout git config –global alias.st status git config –global alias.undo “reset HEAD~1 –mixed”
Fazit¶
Diese Befehle decken 95% aller Situationen ab. Lernen Sie sie einzeln — in einem Monat sind Sie ein Git-Ninja.