Learning
Git CLI

Gyakorlati Git workflow-k

Feature branch, hotfix, stash és fork-alapú open source workflow-k lépésről lépésre.

Gyakorlati workflow példák

Feature Branch Workflow

Ez a legelterjedtebb csapat workflow:

# 1. Szinkronizáljuk a mainet
git switch main
git pull --rebase origin main

# 2. Létrehozzuk a feature branch-et
git switch -c feature/user-notifications

# 3. Dolgozunk, commitálunk
git add src/notifications/
git commit -m "feat(notifications): add email notification service"

git add src/notifications/types.ts
git commit -m "feat(notifications): define notification types"

# 4. Szinkronizáljuk a feature branch-et a frissített main alapján
git fetch origin
git rebase origin/main

# 5. Konfliktus esetén feloldjuk, majd folytatjuk
git add src/conflicted-file.ts
git rebase --continue

# 6. Interaktív rebase: history szépítés push előtt
git rebase -i origin/main

# 7. Feltöltés
git push -u origin feature/user-notifications

# 8. Pull Request / Merge Request nyitása a UI-on (GitHub, GitLab)

# 9. Merge után takarítás
git switch main
git pull
git branch -d feature/user-notifications
git push origin --delete feature/user-notifications

Hotfix Workflow

Kritikus hiba gyors javítása a production-ön:

# 1. Hotfix branch a mainből (vagy release ágból)
git switch main
git pull
git switch -c hotfix/fix-payment-null-pointer

# 2. Javítás és commit
git add src/payment/processor.ts
git commit -m "fix(payment): handle null pointer in processor"

# 3. Feltöltés és PR nyitása
git push -u origin hotfix/fix-payment-null-pointer

# 4. Merge után tag a verzióhoz
git switch main
git pull
git tag -a v1.2.1 -m "hotfix: fix payment null pointer"
git push origin v1.2.1

Kód mentése és visszatérés

Megszakított munka biztonságos kezelése:

# Félkész munka mentése és branch váltás
git stash push -m "WIP: refactor auth middleware"
git switch main
git pull
# ... elvégezzük a sürgős feladatot ...

# Visszatérés és a munka folytatása
git switch feature/auth-refactor
git stash pop

Fork-alapú workflow (open source)

# 1. Fork a GitHub UI-on, majd klónozás
git clone git@github.com:sajatfelhasznalo/projekt.git
cd projekt

# 2. Upstream beállítása
git remote add upstream git@github.com:eredeti-szerzo/projekt.git

# 3. Szinkronizálás az upstream-mel
git fetch upstream
git switch main
git merge upstream/main

# 4. Feature branch és fejlesztés
git switch -c fix/typo-in-readme
# ... módosítás ...
git commit -m "docs: fix typo in README"
git push origin fix/typo-in-readme

# 5. Pull Request nyitása a GitHub UI-on

Rövid összefoglaló

  • A Feature Branch Workflow az iparági standard: mindig branch-en dolgozz.
  • Hotfix esetén a main-ből (vagy release branch-ből) ágazz el, majd mergeld vissza és tageld.
  • git stash segít a gyors branch-váltásoknál anélkül, hogy idő előtt commitálnál.
  • Fork workflow esetén az upstream remote biztosítja a szinkronizálást.
  • Pull Request nyitása előtt mindig rebase-eld a branch-et a legfrissebb main alapján.

On this page