From 7fb84560f5bcf60ecd7a32a0a8f74ba864edc360 Mon Sep 17 00:00:00 2001 From: Bjarke Sporring Date: Wed, 7 Jan 2026 21:37:21 +0100 Subject: [PATCH] use switch instead of checkout for branches --- 01_essentials/03-branching/README.md | 6 +++--- 01_essentials/03-branching/verify.ps1 | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/01_essentials/03-branching/README.md b/01_essentials/03-branching/README.md index 37bbf00..cc361db 100644 --- a/01_essentials/03-branching/README.md +++ b/01_essentials/03-branching/README.md @@ -43,12 +43,12 @@ Your goal is to create a feature branch, make commits on it, and understand how 5. Stage and commit: `git add login.py` and `git commit -m "Add login functionality"` 6. Modify `login.py`, then commit again 7. Switch back to main: `git switch main` -8. Run `ls` and notice that `login.py` doesn't exist on main! +8. Run `ls` (or check your file explorer) and notice that `login.py` doesn't exist on main! 9. Switch back to feature-login: `git switch feature-login` -10. Run `ls` again and see that `login.py` is back! +10. Run `ls` (or check your file explorer) again and see that `login.py` is back! > **Important Notes:** -> - Use `git switch` to change branches (modern Git command) +> - Use `git switch` to change branches > - `git switch -c ` creates and switches in one command > - Branches are independent - files in one branch don't affect another until you merge > - You can switch between branches as many times as you want diff --git a/01_essentials/03-branching/verify.ps1 b/01_essentials/03-branching/verify.ps1 index eebc44c..b8b3eb0 100644 --- a/01_essentials/03-branching/verify.ps1 +++ b/01_essentials/03-branching/verify.ps1 @@ -40,7 +40,7 @@ if ($branchExists) { Write-Host "[PASS] Branch 'feature-login' exists" -ForegroundColor Green } else { Write-Host "[FAIL] Branch 'feature-login' not found" -ForegroundColor Red - Write-Host "[HINT] Create the branch with: git checkout -b feature-login" -ForegroundColor Yellow + Write-Host "[HINT] Create the branch with: git switch -c feature-login" -ForegroundColor Yellow $allChecksPassed = $false Set-Location .. exit 1 @@ -67,7 +67,7 @@ if (Test-Path "login.py") { } # Switch to main and verify login.py doesn't exist -git checkout main 2>$null | Out-Null +git switch main 2>$null | Out-Null if (-not (Test-Path "login.py")) { Write-Host "[PASS] File 'login.py' does NOT exist in main branch (branches are independent!)" -ForegroundColor Green } else { @@ -78,7 +78,7 @@ if (-not (Test-Path "login.py")) { # Switch back to original branch if ($originalBranch) { - git checkout $originalBranch 2>$null | Out-Null + git switch $originalBranch 2>$null | Out-Null } Set-Location .. @@ -91,7 +91,7 @@ if ($allChecksPassed) { Write-Host "=====================================" -ForegroundColor Green Write-Host "`nYou've successfully learned about Git branches!" -ForegroundColor Cyan Write-Host "You now understand:" -ForegroundColor Cyan - Write-Host " - How to create branches with git checkout -b" -ForegroundColor White + Write-Host " - How to create branches with git switch -c" -ForegroundColor White Write-Host " - How to switch between branches" -ForegroundColor White Write-Host " - That branches are independent lines of development" -ForegroundColor White Write-Host " - That files in one branch don't affect another" -ForegroundColor White