Compare commits
3 Commits
e2e36690ea
...
refactor-r
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6cf0418ebd | ||
|
|
a8e9507f89 | ||
|
|
a895abdd03 |
@@ -307,44 +307,6 @@ git merge main
|
||||
git pull origin main
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "I'm on the wrong branch!"
|
||||
|
||||
```pwsh
|
||||
# Switch to the correct branch
|
||||
git switch correct-branch
|
||||
|
||||
# Check current branch anytime
|
||||
git branch
|
||||
```
|
||||
|
||||
### "I made commits on the wrong branch!"
|
||||
|
||||
Don't panic! You can move commits to another branch:
|
||||
|
||||
```pwsh
|
||||
# Create the correct branch from current state
|
||||
git branch correct-branch
|
||||
|
||||
# Switch to wrong branch and remove the commits
|
||||
git switch wrong-branch
|
||||
git reset --hard HEAD~2 # Remove last 2 commits (adjust number)
|
||||
|
||||
# Switch to correct branch - commits are there!
|
||||
git switch correct-branch
|
||||
```
|
||||
|
||||
### "The merge created unexpected results!"
|
||||
|
||||
```pwsh
|
||||
# Undo the merge
|
||||
git merge --abort
|
||||
|
||||
# Or if already committed:
|
||||
git reset --hard HEAD~1
|
||||
```
|
||||
|
||||
### "I want to see what changed in a merge!"
|
||||
|
||||
```pwsh
|
||||
@@ -368,13 +330,13 @@ git diff main..feature-branch
|
||||
|
||||
After completing this module, you understand:
|
||||
|
||||
- ✅ Branches create independent lines of development
|
||||
- ✅ `git switch -c` creates a new branch
|
||||
- ✅ Changes in one branch don't affect others
|
||||
- ✅ `git merge` combines branches
|
||||
- ✅ Merge commits have two parent commits
|
||||
- ✅ `git log --graph` visualizes branch history
|
||||
- ✅ Branches are pointers, not copies of files
|
||||
- Branches create independent lines of development
|
||||
- `git switch -c` creates a new branch
|
||||
- Changes in one branch don't affect others
|
||||
- `git merge` combines branches
|
||||
- Merge commits have two parent commits
|
||||
- `git log --graph` visualizes branch history
|
||||
- Branches are pointers, not copies of files
|
||||
|
||||
## Next Steps
|
||||
|
||||
|
||||
@@ -235,5 +235,3 @@ To reuse the repository:
|
||||
- **Keep groups small** (2 people per repository) for more interaction
|
||||
- **Encourage communication** - the exercise works best when people talk
|
||||
- **Let conflicts happen** - they're the best learning opportunity
|
||||
- **Walk the room** - help students who get stuck
|
||||
- **Point students to 03_TASKS.md** - Simple explanations of clone, push, pull, and fetch for beginners
|
||||
|
||||
@@ -61,7 +61,7 @@ Enter file in which to save the key (/Users/yourname/.ssh/id_rsa):
|
||||
|
||||
### Passphrase (Optional but Recommended)
|
||||
|
||||
You'll be prompted to enter a passphrase, just press `Enter` no password is needed:
|
||||
You'll be prompted to enter a passphrase, just press `Enter` no password is needed (recommended but not needed):
|
||||
|
||||
```
|
||||
Enter passphrase (empty for no passphrase):
|
||||
@@ -72,7 +72,6 @@ Enter same passphrase again:
|
||||
|
||||
Check that your keys were created:
|
||||
|
||||
**Linux/Mac:**
|
||||
**Windows PowerShell:**
|
||||
```powershell
|
||||
dir $HOME\.ssh\
|
||||
@@ -164,33 +163,14 @@ git clone git@ssh.dev.azure.com:v3/myorg/git-workshop/great-print-project
|
||||
|
||||
**How to find your SSH URL:**
|
||||
1. Navigate to your repository in Azure DevOps
|
||||

|
||||
2. Click **Clone** in the top-right
|
||||
3. Select **SSH** from the dropdown
|
||||
4. Copy the SSH URL
|
||||
|
||||

|
||||

|
||||
*Select SSH from the clone dialog to get your repository's SSH URL*
|
||||
|
||||
### Convert Existing HTTPS Repository to SSH
|
||||
|
||||
If you already cloned a repository using HTTPS, you can switch it to SSH:
|
||||
|
||||
```bash
|
||||
cd /path/to/your/repository
|
||||
git remote set-url origin git@ssh.dev.azure.com:v3/{organization}/{project}/{repository}
|
||||
```
|
||||
|
||||
**Verify the change:**
|
||||
```bash
|
||||
git remote -v
|
||||
```
|
||||
|
||||
You should see SSH URLs:
|
||||
```
|
||||
origin git@ssh.dev.azure.com:v3/myorg/git-workshop/great-print-project (fetch)
|
||||
origin git@ssh.dev.azure.com:v3/myorg/git-workshop/great-print-project (push)
|
||||
```
|
||||
|
||||
### Daily Git Operations
|
||||
|
||||
All standard Git commands now work seamlessly with SSH:
|
||||
@@ -214,7 +194,6 @@ git push -u origin feature-branch
|
||||
---
|
||||
|
||||
## Additional Resources
|
||||
|
||||
- **Azure DevOps SSH Documentation**: [https://docs.microsoft.com/en-us/azure/devops/repos/git/use-ssh-keys-to-authenticate](https://docs.microsoft.com/en-us/azure/devops/repos/git/use-ssh-keys-to-authenticate)
|
||||
- **SSH Key Best Practices**: [https://security.stackexchange.com/questions/tagged/ssh-keys](https://security.stackexchange.com/questions/tagged/ssh-keys)
|
||||
- **Git with SSH**: [https://git-scm.com/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key](https://git-scm.com/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key)
|
||||
@@ -235,15 +214,9 @@ cat ~/.ssh/id_rsa.pub
|
||||
# Display public key (Windows)
|
||||
type $HOME\.ssh\id_rsa.pub
|
||||
|
||||
# Test SSH connection
|
||||
ssh -T git@ssh.dev.azure.com
|
||||
|
||||
# Clone with SSH
|
||||
git clone git@ssh.dev.azure.com:v3/{org}/{project}/{repo}
|
||||
|
||||
# Convert HTTPS to SSH
|
||||
git remote set-url origin git@ssh.dev.azure.com:v3/{org}/{project}/{repo}
|
||||
|
||||
# Check remote URL
|
||||
git remote -v
|
||||
```
|
||||
@@ -256,7 +229,7 @@ git@ssh.dev.azure.com:v3/{organization}/{project}/{repository}
|
||||
|
||||
**Example:**
|
||||
```
|
||||
git@ssh.dev.azure.com:v3/mycompany/git-workshop/great-print-project
|
||||
git@ssh.dev.azure.com:v3/novenco/software/git-workshop
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
148
01-essentials/08-multiplayer/README.md
Normal file
148
01-essentials/08-multiplayer/README.md
Normal 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
|
||||
```
|
||||
BIN
01-essentials/08-multiplayer/images/05_repos.png
Normal file
BIN
01-essentials/08-multiplayer/images/05_repos.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 53 KiB |
BIN
01-essentials/08-multiplayer/images/06_choose_ssh.png
Normal file
BIN
01-essentials/08-multiplayer/images/06_choose_ssh.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 165 KiB |
Reference in New Issue
Block a user