1 Commits

Author SHA1 Message Date
Bjarke Sporring
a895abdd03 feat: drastically simplify tasks for multiplayer 2026-01-15 17:30:03 +01:00

View File

@@ -0,0 +1,148 @@
# Multiplayer Git
Work with others using branches and pull requests.
## Goal
Learn to collaborate on a shared repository using:
- **Branches** - work independently without breaking main
- **Pull Requests** - review and merge changes safely
## The Workflow
```
1. Create branch → 2. Make changes → 3. Push branch
6. Delete branch ← 5. Merge PR ← 4. Create PR
```
This is how professional teams work together on code.
---
## Step 1: Clone the Repository
Get the repository URL from your facilitator, then:
```powershell
git clone <repository-url>
code <repository-name>
```
---
## Step 2: Create a Branch
Never work directly on `main`. Create your own branch:
```powershell
git switch -c <branch>
```
This creates a new branch and switches to it.
---
## Step 3: Make Changes
1. Open `numbers.txt` in VS Code
2. Move one number to its correct position
3. Save the file (`Ctrl+S`)
---
## Step 4: Commit and Push
```powershell
git add .
git commit -m "fix: move 7 to correct position"
git push feature-2
```
Your branch is now on Azure DevOps.
---
## Step 5: Create a Pull Request
1. Go to Azure DevOps in your browser
2. Navigate to **Repos****Pull Requests**
3. Click **New Pull Request**
4. Set:
- **Source branch:** `feature/<your-name>`
- **Target branch:** `main`
5. Add a title describing your change
6. Click **Create**
---
## Step 6: Review and Merge
1. Review the changes shown in the PR
2. If everything looks good, click **Complete**
3. Select **Complete merge**
4. Your changes are now in `main`
---
## Step 7: Update Your Local Main
After merging, update your local copy:
```powershell
git switch main
git pull
```
---
## Step 8: Repeat
1. Create a new branch for your next change
2. Make changes, commit, push
3. Create another PR
4. Continue until all numbers are sorted
---
## Quick Reference
| Command | What It Does |
|---------|--------------|
| `git switch -c <name>` | Create and switch to new branch |
| `git push -u origin <branch>` | Push branch to Azure DevOps |
| `git switch main` | Switch to main branch |
| `git pull` | Get latest changes from remote |
---
## Common Issues
### "I accidentally committed to main"
Switch to a new branch and push from there:
```powershell
git switch -c feature/<your-name>
git push -u origin feature/<your-name>
```
### "My PR has conflicts"
1. Update your branch with latest main:
```powershell
git switch main
git pull
git switch feature/<your-name>
git merge main
```
2. Resolve conflicts in VS Code
3. Commit and push again
### "I need to make more changes to my PR"
Just commit and push to the same branch - the PR updates automatically:
```powershell
git add .
git commit -m "fix: address review feedback"
git push
```