diff --git a/01-essentials/08-multiplayer/README.md b/01-essentials/08-multiplayer/README.md new file mode 100644 index 0000000..60b9022 --- /dev/null +++ b/01-essentials/08-multiplayer/README.md @@ -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 +code +``` + +--- + +## Step 2: Create a Branch + +Never work directly on `main`. Create your own branch: + +```powershell +git switch -c +``` + +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/` + - **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 ` | Create and switch to new branch | +| `git push -u origin ` | 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/ +git push -u origin feature/ +``` + +### "My PR has conflicts" + +1. Update your branch with latest main: + ```powershell + git switch main + git pull + git switch feature/ + 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 +```