59 lines
2.1 KiB
Markdown
59 lines
2.1 KiB
Markdown
# 09 — Branches and pull requests
|
|||
|
|
|
||
|
|
🌍 **English** · [Türkçe](../../tr/09-branches-and-pull-requests/readme.md) · [Deutsch](../../de/09-branches-and-pull-requests/readme.md) · [Français](../../fr/09-branches-and-pull-requests/readme.md) · [Русский](../../ru/09-branches-and-pull-requests/readme.md)
|
||
|
|
|
||
|
|
A branch is a safe copy of the project where you can work without disturbing `main`. A pull request is the request to bring that work back.
|
||
|
|
|
||
|
|
## When you need a branch
|
||
|
|
|
||
|
|
- The change is big enough that half-finished work would break things.
|
||
|
|
- Somebody should look at it before it goes live.
|
||
|
|
- You want to try an idea and be able to throw it away.
|
||
|
|
|
||
|
|
For a typo in a document, committing straight to `main` is fine.
|
||
|
|
|
||
|
|
## Creating a branch in the browser
|
||
|
|
|
||
|
|
While committing (chapter 03), choose **Create a new branch for this commit and start a pull request**, name the branch, and commit. Good names describe the work:
|
||
|
|
|
||
|
|
```
|
||
|
|
docs/vlan-notes
|
||
|
|
fix/wrong-gateway
|
||
|
|
feature/report-export
|
||
|
|
```
|
||
|
|
|
||
|
|
## Opening a pull request
|
||
|
|
|
||
|
|
1. Go to **Pull Requests → New Pull Request**.
|
||
|
|
2. Pick the source branch (yours) and the target (`main`).
|
||
|
|
3. Title = what the change does. Description = why, plus anything reviewers should check.
|
||
|
|
4. Press **Create Pull Request**.
|
||
|
|
|
||
|
|
## Review
|
||
|
|
|
||
|
|
- Reviewers comment on individual lines from the **Files Changed** tab.
|
||
|
|
- Push more commits to the same branch — the pull request updates itself.
|
||
|
|
- When it is approved, press **Merge Pull Request**, then delete the branch.
|
||
|
|
|
||
|
|
## Merge conflicts
|
||
|
|
|
||
|
|
If `main` changed the same lines you did, KabaForge asks you to resolve it. From your computer:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
git switch my-branch
|
||
|
|
git fetch origin
|
||
|
|
git merge origin/main
|
||
|
|
# open the marked files, keep the correct lines
|
||
|
|
git add .
|
||
|
|
git commit
|
||
|
|
git push
|
||
|
|
```
|
||
|
|
|
||
|
|
## Protecting `main`
|
||
|
|
|
||
|
|
**Settings → Branches → Add rule**: require pull requests and approvals before anything reaches `main`. Recommended as soon as more than one person works in the repository.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
⬅ [Previous: 08 — Commits and history](../08-commits-and-history/readme.md) · 📚 [Contents](../README.md) · [Next: 10 — Working from your computer](../10-clone-and-tokens/readme.md) ➡
|