Git Workflow¶
Робочий процес з Git для командної розробки.
Налаштування¶
Глобальна конфігурація¶
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
git config --global init.defaultBranch main
git config --global pull.rebase true
SSH ключі¶
# Генерація ключа
ssh-keygen -t ed25519 -C "your@email.com"
# Запуск ssh-agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
# Копіювання публічного ключа
cat ~/.ssh/id_ed25519.pub
Основні команди¶
Робота з репозиторієм¶
# Клонування
git clone git@git.eliah.one:mytec/project.git
# Статус
git status
# Історія
git log --oneline -10
Зміни¶
# Додати файли
git add .
# Commit
git commit -m "feat: add new feature"
# Push
git push origin main
Гілки¶
# Створити гілку
git checkout -b feature/new-feature
# Переключитись на гілку
git checkout main
# Список гілок
git branch -a
# Видалити гілку
git branch -d feature/old-feature
Workflow¶
Feature Branch Workflow¶
1. Оновити main
git checkout main
git pull origin main
2. Створити feature гілку
git checkout -b feature/my-feature
3. Зробити зміни та commit
git add .
git commit -m "feat: implement feature"
4. Push та створити PR
git push origin feature/my-feature
5. Після merge видалити гілку
git checkout main
git pull origin main
git branch -d feature/my-feature
Формат commit повідомлень¶
type: short description
feat: нова функціональність
fix: виправлення бага
docs: документація
refactor: рефакторинг
test: тести
chore: обслуговування
Приклади:
feat: add user authentication
fix: resolve login timeout issue
docs: update API documentation
Корисні команди¶
Скасування змін¶
# Скасувати зміни в файлі
git checkout -- filename
# Скасувати останній commit (зберегти зміни)
git reset --soft HEAD~1
# Повернутись до конкретного commit
git reset --hard commit_hash
Stash¶
# Зберегти зміни тимчасово
git stash
# Відновити зміни
git stash pop
# Список stash
git stash list
Rebase¶
# Оновити feature гілку
git checkout feature/my-feature
git rebase main
# Інтерактивний rebase
git rebase -i HEAD~3
Конфлікти¶
Вирішення конфліктів¶
# При merge conflict
git status # побачити файли з конфліктами
# Редагувати файли, видалити маркери конфлікту
# <<<<<<< HEAD
# ваші зміни
# =======
# їхні зміни
# >>>>>>> branch
git add .
git commit -m "resolve merge conflicts"
Аліаси¶
Додайте в ~/.gitconfig:
[alias]
st = status
co = checkout
br = branch
ci = commit
lg = log --oneline --graph -10
last = log -1 HEAD
unstage = reset HEAD --
Шлях: getting-started/git-workflow.md