Compare commits
10 Commits
advanced-c
...
cba2d9bb16
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cba2d9bb16 | ||
|
|
968a44f9a5 | ||
|
|
c39573573f | ||
|
|
ee67433fdd | ||
|
|
100e89b23d | ||
| b58080b8e8 | |||
|
|
6cf0418ebd | ||
|
|
a8e9507f89 | ||
| 2240cbe10d | |||
|
|
a895abdd03 |
@@ -307,44 +307,6 @@ git merge main
|
|||||||
git pull origin 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!"
|
### "I want to see what changed in a merge!"
|
||||||
|
|
||||||
```pwsh
|
```pwsh
|
||||||
@@ -368,13 +330,13 @@ git diff main..feature-branch
|
|||||||
|
|
||||||
After completing this module, you understand:
|
After completing this module, you understand:
|
||||||
|
|
||||||
- ✅ Branches create independent lines of development
|
- Branches create independent lines of development
|
||||||
- ✅ `git switch -c` creates a new branch
|
- `git switch -c` creates a new branch
|
||||||
- ✅ Changes in one branch don't affect others
|
- Changes in one branch don't affect others
|
||||||
- ✅ `git merge` combines branches
|
- `git merge` combines branches
|
||||||
- ✅ Merge commits have two parent commits
|
- Merge commits have two parent commits
|
||||||
- ✅ `git log --graph` visualizes branch history
|
- `git log --graph` visualizes branch history
|
||||||
- ✅ Branches are pointers, not copies of files
|
- Branches are pointers, not copies of files
|
||||||
|
|
||||||
## Next Steps
|
## Next Steps
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
By the end of this module, you will:
|
By the end of this module, you will:
|
||||||
- Understand what cherry-picking is and how it works
|
- Understand what cherry-picking is and how it works
|
||||||
- Know when to use cherry-pick vs merge or rebase
|
- Know when to use cherry-pick vs merge
|
||||||
- Apply specific commits from one branch to another
|
- Apply specific commits from one branch to another
|
||||||
- Understand common use cases for cherry-picking
|
- Understand common use cases for cherry-picking
|
||||||
- Learn how cherry-pick creates new commits with different hashes
|
- Learn how cherry-pick creates new commits with different hashes
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ Participants need:
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Pre-Workshop Setup
|
## Setup
|
||||||
|
|
||||||
### Step 1: Add User Accounts
|
### Step 1: Add User Accounts
|
||||||
|
|
||||||
@@ -131,15 +131,6 @@ git add numbers.txt
|
|||||||
git commit -m "feat: add shuffled numbers for challenge"
|
git commit -m "feat: add shuffled numbers for challenge"
|
||||||
git push
|
git push
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step 4: Verify Student Access
|
|
||||||
|
|
||||||
Students added to the project automatically have access. Verify:
|
|
||||||
|
|
||||||
1. Go to **Project Settings** → **Repositories** → **number-challenge**
|
|
||||||
2. Click **Security** tab
|
|
||||||
3. Verify project team has **Contribute** permission
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## During the Workshop
|
## During the Workshop
|
||||||
@@ -153,12 +144,12 @@ Students added to the project automatically have access. Verify:
|
|||||||
### The Exercise Flow
|
### The Exercise Flow
|
||||||
|
|
||||||
1. **Students pull** the latest changes
|
1. **Students pull** the latest changes
|
||||||
2. **One person** moves a number to its correct position
|
2. **One person** creates a branch, moves a number to its correct position
|
||||||
3. **They commit and push**
|
3. **They commit and push**
|
||||||
4. **Others pull** and see the change
|
4. **Others pull** and see the change
|
||||||
5. **Repeat** until sorted
|
5. **Repeat** until sorted
|
||||||
|
|
||||||
### Creating Conflicts (The Learning Moment)
|
### Same branch conflicts
|
||||||
|
|
||||||
Conflicts happen naturally when multiple people edit at once. You can encourage this:
|
Conflicts happen naturally when multiple people edit at once. You can encourage this:
|
||||||
|
|
||||||
@@ -166,13 +157,6 @@ Conflicts happen naturally when multiple people edit at once. You can encourage
|
|||||||
- Watch them experience the push rejection
|
- Watch them experience the push rejection
|
||||||
- Guide them through pulling and resolving the conflict
|
- Guide them through pulling and resolving the conflict
|
||||||
|
|
||||||
### Monitoring Progress
|
|
||||||
|
|
||||||
Check progress in Azure DevOps:
|
|
||||||
|
|
||||||
- **Repos → Commits**: See who's contributing
|
|
||||||
- **Repos → Files → numbers.txt**: See current state
|
|
||||||
|
|
||||||
### Common Issues
|
### Common Issues
|
||||||
|
|
||||||
**"I can't push!"**
|
**"I can't push!"**
|
||||||
@@ -235,5 +219,3 @@ To reuse the repository:
|
|||||||
- **Keep groups small** (2 people per repository) for more interaction
|
- **Keep groups small** (2 people per repository) for more interaction
|
||||||
- **Encourage communication** - the exercise works best when people talk
|
- **Encourage communication** - the exercise works best when people talk
|
||||||
- **Let conflicts happen** - they're the best learning opportunity
|
- **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
|
|
||||||
|
|||||||
@@ -20,15 +20,15 @@ SSH (Secure Shell) keys provide a secure way to authenticate with Azure DevOps w
|
|||||||
Before starting, ensure you have:
|
Before starting, ensure you have:
|
||||||
|
|
||||||
- **Git 2.23 or higher** installed
|
- **Git 2.23 or higher** installed
|
||||||
```powershell
|
```pwsh
|
||||||
git --version
|
git --version
|
||||||
```
|
```
|
||||||
|
|
||||||
- **Azure DevOps account** with access to your organization/project
|
- **Azure DevOps account** with access to your organization/project
|
||||||
- If you don't have one, create a free account at [dev.azure.com](https://dev.azure.com)
|
- If you don't ask your organisation for an invitation
|
||||||
|
|
||||||
- **PowerShell 7+ or Bash terminal** for running commands
|
- **PowerShell 7+ or Bash terminal** for running commands
|
||||||
```powershell
|
```pwsh
|
||||||
pwsh --version
|
pwsh --version
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -42,18 +42,18 @@ SSH authentication uses a key pair: a private key (stays on your computer) and a
|
|||||||
|
|
||||||
Open your terminal and run:
|
Open your terminal and run:
|
||||||
|
|
||||||
```powershell
|
```pwsh
|
||||||
ssh-keygen -t rsa
|
ssh-keygen -t rsa
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note about RSA:** Azure DevOps currently only supports RSA SSH keys. While newer algorithms like Ed25519 offer better security and performance, they are not yet supported by Azure DevOps. See the note at the end of this guide for more information.
|
**Note about RSA:** Azure DevOps currently only supports RSA SSH keys. While newer algorithms like Ed25519 offer better security and performance, they are not yet supported by Azure DevOps.
|
||||||
|
|
||||||
### Save Location
|
### Save Location
|
||||||
|
|
||||||
When prompted for the file location, press `Enter` to accept the default:
|
When prompted for the file location, press `Enter` to accept the default:
|
||||||
|
|
||||||
```
|
```
|
||||||
Enter file in which to save the key (/Users/yourname/.ssh/id_rsa):
|
Enter file in which to save the key (C:\Users\YourName\.ssh\id_rsa):
|
||||||
```
|
```
|
||||||
|
|
||||||
**Default locations:**
|
**Default locations:**
|
||||||
@@ -61,7 +61,7 @@ Enter file in which to save the key (/Users/yourname/.ssh/id_rsa):
|
|||||||
|
|
||||||
### Passphrase (Optional but Recommended)
|
### 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):
|
Enter passphrase (empty for no passphrase):
|
||||||
@@ -72,9 +72,8 @@ Enter same passphrase again:
|
|||||||
|
|
||||||
Check that your keys were created:
|
Check that your keys were created:
|
||||||
|
|
||||||
**Linux/Mac:**
|
|
||||||
**Windows PowerShell:**
|
**Windows PowerShell:**
|
||||||
```powershell
|
```pwsh
|
||||||
dir $HOME\.ssh\
|
dir $HOME\.ssh\
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -109,27 +108,17 @@ Now you'll upload your public key to Azure DevOps.
|
|||||||
|
|
||||||
Open your terminal and display your public key:
|
Open your terminal and display your public key:
|
||||||
|
|
||||||
**Linux/Mac:**
|
|
||||||
```bash
|
|
||||||
cat ~/.ssh/id_rsa.pub
|
|
||||||
```
|
|
||||||
|
|
||||||
**Windows PowerShell:**
|
**Windows PowerShell:**
|
||||||
```powershell
|
```pwsh
|
||||||
type $HOME\.ssh\id_rsa.pub
|
type $HOME\.ssh\id_rsa.pub
|
||||||
```
|
```
|
||||||
|
|
||||||
**Windows Command Prompt:**
|
|
||||||
```cmd
|
|
||||||
type %USERPROFILE%\.ssh\id_rsa.pub
|
|
||||||
```
|
|
||||||
|
|
||||||
The output will look like this:
|
The output will look like this:
|
||||||
```
|
```
|
||||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC2YbXnrSK5TTflZSwUv9KUedvI4p3JJ4dHgwp/SeJGqMNWnOMDbzQQzYT7E39w9Q8ItrdWsK4vRLGY2B1rQ+BpS6nn4KhTanMXLTaUFDlg6I1Yn5S3cTTe8dMAoa14j3CZfoSoRRgK8E+ktNb0o0nBMuZJlLkgEtPIz28fwU1vcHoSK7jFp5KL0pjf37RYZeHkbpI7hdCG2qHtdrC35gzdirYPJOekErF5VFRrLZaIRSSsX0V4XzwY2k1hxM037o/h6qcTLWfi5ugbyrdscL8BmhdGNH4Giwqd1k3MwSyiswRuAuclYv27oKnFVBRT+n649px4g3Vqa8dh014wM2HDjMGENIkHx0hcV9BWdfBfTSCJengmosGW+wQfmaNUo4WpAbwZD73ALNsoLg5Yl1tB6ZZ5mHwLRY3LG2BbQZMZRCELUyvbh8ZsRksNN/2zcS44RIQdObV8/4hcLse30+NQ7GRaMnJeAMRz4Rpzbb02y3w0wNQFp/evj1nN4WTz6l8= your@email.com
|
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC2YbXnrSK5TTflZSwUv9KUedvI4p3JJ4dHgwp/SeJGqMNWnOMDbzQQzYT7E39w9Q8ItrdWsK4vRLGY2B1rQ+BpS6nn4KhTanMXLTaUFDlg6I1Yn5S3cTTe8dMAoa14j3CZfoSoRRgK8E+ktNb0o0nBMuZJlLkgEtPIz28fwU1vcHoSK7jFp5KL0pjf37RYZeHkbpI7hdCG2qHtdrC35gzdirYPJOekErF5VFRrLZaIRSSsX0V4XzwY2k1hxM037o/h6qcTLWfi5ugbyrdscL8BmhdGNH4Giwqd1k3MwSyiswRuAuclYv27oKnFVBRT+n649px4g3Vqa8dh014wM2HDjMGENIkHx0hcV9BWdfBfTSCJengmosGW+wQfmaNUo4WpAbwZD73ALNsoLg5Yl1tB6ZZ5mHwLRY3LG2BbQZMZRCELUyvbh8ZsRksNN/2zcS44RIQdObV8/4hcLse30+NQ7GRaMnJeAMRz4Rpzbb02y3w0wNQFp/evj1nN4WTz6l8= your@email.com
|
||||||
```
|
```
|
||||||
|
|
||||||
**Copy the entire output** (from `ssh-rsa` to your email address).
|
**Copy the entire output** (from `ssh-rsa` to and including your email address).
|
||||||
|
|
||||||
|
|
||||||
### Paste and Name Your Key
|
### Paste and Name Your Key
|
||||||
@@ -153,49 +142,30 @@ Now that SSH is configured, you can use it for all Git operations.
|
|||||||
|
|
||||||
To clone a repository using SSH:
|
To clone a repository using SSH:
|
||||||
|
|
||||||
```bash
|
```pwsh
|
||||||
git clone git@ssh.dev.azure.com:v3/{organization}/{project}/{repository}
|
git clone git@ssh.dev.azure.com:v3/{organization}/{project}/{repository}
|
||||||
```
|
```
|
||||||
|
|
||||||
**Example** (replace placeholders with your actual values):
|
**Example** (replace placeholders with your actual values):
|
||||||
```bash
|
```pwsh
|
||||||
git clone git@ssh.dev.azure.com:v3/myorg/git-workshop/great-print-project
|
git clone git@ssh.dev.azure.com:v3/myorg/git-workshop/great-print-project
|
||||||
```
|
```
|
||||||
|
|
||||||
**How to find your SSH URL:**
|
**How to find your SSH URL:**
|
||||||
1. Navigate to your repository in Azure DevOps
|
1. Navigate to your repository in Azure DevOps
|
||||||
|

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

|

|
||||||
*Select SSH from the clone dialog to get your repository's 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
|
### Daily Git Operations
|
||||||
|
|
||||||
All standard Git commands now work seamlessly with SSH:
|
All standard Git commands now work seamlessly with SSH:
|
||||||
|
|
||||||
```bash
|
```pwsh
|
||||||
# Pull latest changes
|
# Pull latest changes
|
||||||
git pull
|
git pull
|
||||||
|
|
||||||
@@ -214,9 +184,7 @@ git push -u origin feature-branch
|
|||||||
---
|
---
|
||||||
|
|
||||||
## Additional Resources
|
## 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)
|
- **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)
|
- **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)
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -225,25 +193,16 @@ git push -u origin feature-branch
|
|||||||
|
|
||||||
### Common Commands
|
### Common Commands
|
||||||
|
|
||||||
```bash
|
```pwsh
|
||||||
# Generate RSA key
|
# Generate RSA key
|
||||||
ssh-keygen -t
|
ssh-keygen -t
|
||||||
|
|
||||||
# Display public key (Linux/Mac)
|
# Display public key
|
||||||
cat ~/.ssh/id_rsa.pub
|
|
||||||
|
|
||||||
# Display public key (Windows)
|
|
||||||
type $HOME\.ssh\id_rsa.pub
|
type $HOME\.ssh\id_rsa.pub
|
||||||
|
|
||||||
# Test SSH connection
|
# Clone with SSH. You can find this url on Azure DevOps
|
||||||
ssh -T git@ssh.dev.azure.com
|
|
||||||
|
|
||||||
# Clone with SSH
|
|
||||||
git clone git@ssh.dev.azure.com:v3/{org}/{project}/{repo}
|
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
|
# Check remote URL
|
||||||
git remote -v
|
git remote -v
|
||||||
```
|
```
|
||||||
@@ -256,7 +215,7 @@ git@ssh.dev.azure.com:v3/{organization}/{project}/{repository}
|
|||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
```
|
```
|
||||||
git@ssh.dev.azure.com:v3/mycompany/git-workshop/great-print-project
|
git@ssh.dev.azure.com:v3/novenco/software/git-workshop
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ Learn to collaborate on a shared repository using:
|
|||||||
|
|
||||||
```
|
```
|
||||||
1. Create branch → 2. Make changes → 3. Push branch
|
1. Create branch → 2. Make changes → 3. Push branch
|
||||||
↓
|
|
||||||
6. Delete branch ← 5. Merge PR ← 4. Create PR
|
6. Delete branch ← 5. Merge PR ← 4. Create PR
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -110,9 +109,15 @@ git pull
|
|||||||
|
|
||||||
1. Both people should create a branch with changes to `feature-1` and `feature-2`, you task is to change the position of number 5. Where you place it is up to you.
|
1. Both people should create a branch with changes to `feature-1` and `feature-2`, you task is to change the position of number 5. Where you place it is up to you.
|
||||||
2. Now both people should push their respective branch `git push <the-branch>`
|
2. Now both people should push their respective branch `git push <the-branch>`
|
||||||
3. Now merge `feature-1` branch first, going throught the Pull Request flow.
|
1. Person A pushes their branch `git push feature-1`
|
||||||
|
2. Person B pushes their branch `git push feature-2`
|
||||||
|
3. Now merge `feature-1` branch first, going throught the Pull Request flow (see Step 5).
|
||||||
4. Then merge `feature-2` branch second, and notice you'll get a MERGE CONFLICT.
|
4. Then merge `feature-2` branch second, and notice you'll get a MERGE CONFLICT.
|
||||||
5. It is not the owner of `feature-2` branch to resolve the conflict. This is done by merge the `main` branch into `feature-2` locally and so the owner of `feature-2` has to do the following
|
5. The owner of `feature-2` (Person B) is now tasked with resolving the conflict.
|
||||||
|
|
||||||
|
In order to solve merge conflicts through a Shared Server (Azure DevOps) you have to do merges in <q>reverse</q>, meaning: Instead of, like in module <q>03-branching-and-merging</q>, merging the feature-branch into the `main` branch, we merge the `main` branch into the feature branch.
|
||||||
|
|
||||||
|
Doing so ensures that the `main` branch maintains the integrity it's supposed to have and the conflicts are solved on the feature-branch side before being merged into the `main` branch. The idea here being that, we ONLY modify the main branch through merges facilitated (and reviewed) by Pull Requests. We want the `main` branch to be as stable as possible.
|
||||||
```pwsh
|
```pwsh
|
||||||
# First get the latest changes on main
|
# First get the latest changes on main
|
||||||
git switch main
|
git switch main
|
||||||
@@ -123,7 +128,8 @@ git pull
|
|||||||
|
|
||||||
# Now we resolve the merge. We're merging the main branch INTO the feature-2 branch.
|
# Now we resolve the merge. We're merging the main branch INTO the feature-2 branch.
|
||||||
git merge main
|
git merge main
|
||||||
# Resolve the merge conflict in numbers.txt
|
# Resolve the merge conflict in numbers.txt by opening in VSCode and choosing the changes you want.
|
||||||
|
# How you solve it is up to you.
|
||||||
# Once resolved
|
# Once resolved
|
||||||
git add numbers.txt
|
git add numbers.txt
|
||||||
git commit
|
git commit
|
||||||
@@ -137,30 +143,29 @@ git pull
|
|||||||
|
|
||||||
| Command | What It Does |
|
| Command | What It Does |
|
||||||
|---------|--------------|
|
|---------|--------------|
|
||||||
| `git switch -c <name>` | Create and switch to new branch |
|
| `git switch -c <branch-name>` | Create and switch to new branch |
|
||||||
| `git push -u origin <branch>` | Push branch to Azure DevOps |
|
| `git switch <branch-name>` | Switch to branch |
|
||||||
| `git switch main` | Switch to main branch |
|
| `git push` | Push branch to Azure DevOps |
|
||||||
| `git pull` | Get latest changes from remote |
|
| `git pull` | Get latest changes from remote |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Common Issues
|
## Cheatsheet
|
||||||
|
|
||||||
### "My PR has conflicts"
|
### Solving merge conflicts
|
||||||
1. Update your branch with latest main:
|
```pwsh
|
||||||
```powershell
|
git switch main
|
||||||
git switch main
|
git pull
|
||||||
git pull
|
git switch <branch-name>
|
||||||
git switch <branch-name>
|
git merge main
|
||||||
git merge main
|
# ... Solve the conflicts
|
||||||
```
|
git push
|
||||||
2. Resolve conflicts in VS Code
|
```
|
||||||
3. Commit and push again
|
|
||||||
|
|
||||||
### "I need to make more changes to my PR"
|
### "I need to make more changes to my PR"
|
||||||
|
|
||||||
Just commit and push to the same branch - the PR updates automatically:
|
Just commit and push to the same branch - the PR updates automatically:
|
||||||
```powershell
|
```pwsh
|
||||||
git add .
|
git add .
|
||||||
git commit -m "fix: address review feedback"
|
git commit -m "fix: address review feedback"
|
||||||
git push
|
git push
|
||||||
|
|||||||
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 |
50
install.ps1
50
install.ps1
@@ -1,35 +1,39 @@
|
|||||||
#!/usr/bin/env pwsh
|
#!/usr/bin/env pwsh
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Installs all prerequisites for Git Workshop using winget and clones the repository.
|
Installs all prerequisites for Git Workshop using winget (which is a CLI
|
||||||
|
tool to the Windows Package Manager Server) and clones the workshop
|
||||||
|
repository.
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This script automates the installation of required tools for the Git Workshop:
|
This script automates the installation of required tools for the Git Workshop:
|
||||||
- PowerShell 7 (cross-platform PowerShell)
|
- PowerShell 7 (cross-platform PowerShell)
|
||||||
- Git 2.23+ (version control system)
|
- Git 2.23+ (version control system)
|
||||||
- Visual Studio Code (code editor with Git integration)
|
- Visual Studio Code (code editor with Git integration)
|
||||||
|
|
||||||
Optional tools (with user prompts):
|
Optional tools (with user prompts):
|
||||||
- Windows Terminal (modern terminal experience)
|
- Windows Terminal (modern terminal experience)
|
||||||
|
|
||||||
The script checks for existing installations, shows clear progress, and verifies
|
The script checks for existing installations, shows clear progress, and verifies
|
||||||
each installation succeeded. At the end, it clones the repository and can
|
each installation succeeded. At the end, it clones the repository and can
|
||||||
open it in VSCode for immediate workshop access.
|
open it in VSCode for immediate workshop access.
|
||||||
|
|
||||||
One-shot installation:
|
One-shot installation:
|
||||||
Invoke-RestMethod -Uri https://git.frod.dk/floppydiscen/git-workshop/raw/branch/main/install.ps1 | Invoke-Expression
|
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
||||||
|
Invoke-RestMethod -Uri https://git.frod.dk/floppydiscen/git-workshop/raw/branch/main/install.ps1 | Invoke-Expression
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> Invoke-RestMethod -Uri https://git.frod.dk/floppydiscen/git-workshop/raw/branch/main/install.ps1 | Invoke-Expression
|
PS> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
||||||
Runs the complete installation and setup in one command.
|
PS> Invoke-RestMethod -Uri https://git.frod.dk/floppydiscen/git-workshop/raw/branch/main/install.ps1 | Invoke-Expression
|
||||||
|
Runs the complete installation and setup in one command.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> .\install.ps1
|
PS> .\install.ps1
|
||||||
Runs the installation script with interactive prompts.
|
Runs the installation script with interactive prompts.
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Requires Windows 11 with winget (App Installer) available.
|
Requires Windows 11 with winget (App Installer) available.
|
||||||
Some installations may require administrator privileges.
|
Some installations may require administrator privileges.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
|
|||||||
Reference in New Issue
Block a user