Git: 20 команд, которые нужны каждый день
Ветки, коммиты, слияния, откаты, stash и работа с удалёнными репозиториями — компактная шпаргалка.
Начало работы
bash
git clone git@github.com:org/repo.git
git status
git add -p
git commit -m "feat: add nginx role"
git push -u origin mainВетки
bash
git switch -c feature/backup-script
git branch -a
git merge --no-ff feature/backup-script
git rebase main
git branch -d feature/backup-scriptИстория и откаты
bash
git log --oneline --graph --decorate -20
git diff HEAD~1
git restore --staged file.sh
git revert <sha>
git reset --hard origin/mainВременное сохранение
bash
git stash push -m "wip: firewall rules"
git stash list
git stash popУдалённые репозитории
bash
git remote -v
git fetch --prune
git pull --rebase
git reflogспасает, когда кажется, что коммиты потеряны: там хранятся все перемещения HEAD за последние 90 дней.
gitcheatsheet