-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Git worktree lesson #385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Git worktree lesson #385
Conversation
WalkthroughAdded Git worktree documentation and two setup scripts (PowerShell and shell) that create a minimal multi-branch exercise workflow. Expanded Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
worktree/setup.sh (1)
16-16: Consider using modern Git commands.The script uses
git checkoutwhich works but is deprecated in favor of the more intuitivegit switch(available since Git 2.23). This would apply to both branch creation (line 16) and switching (line 26).🔎 Optional modernization
-git checkout -b feature +git switch -c feature-git checkout master +git switch masterNote: This change should be applied consistently across all setup scripts and documentation if adopted.
Also applies to: 26-26
worktree/setup.ps1 (1)
9-9: Consider using modern Git commands.Similar to the shell script, this uses
git checkoutwhich could be replaced with the more intuitivegit switchcommand (available since Git 2.23).🔎 Optional modernization
-git checkout -b feature +git switch -c feature-git checkout master +git switch masterNote: This should be applied consistently with the shell script and documentation.
Also applies to: 19-19
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
.gitignore(1 hunks)worktree/README.md(1 hunks)worktree/setup.ps1(1 hunks)worktree/setup.sh(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
worktree/setup.sh (2)
utils/make-exercise-repo.sh (1)
make-exercise-repo(2-12)utils/make-setup.sh (1)
config-local-username(11-24)
🪛 Shellcheck (0.11.0)
worktree/setup.sh
[warning] 6-6: kata appears unused. Verify use (or export if used externally).
(SC2034)
🔇 Additional comments (4)
.gitignore (1)
5-5: LGTM! Pattern aligns with worktree kata.The new ignore pattern correctly covers worktree directories like
exercise-featurethat will be created as siblings to the mainexercisedirectory during the kata exercise.worktree/README.md (1)
1-58: Excellent documentation structure and clarity!The README provides clear, step-by-step instructions for learning Git worktrees. The worktree paths (e.g.,
../exercise-feature) correctly align with the.gitignorepattern, and the note at the end appropriately explains the placement strategy.Note: If the setup scripts are updated to use
git switchinstead ofgit checkout, the examples in this README should be updated for consistency.worktree/setup.sh (1)
6-6: Thekatavariable is unused in this script and represents dead code.The variable is set to "worktree" on line 6 but is never referenced anywhere in the script or in the sourced utility functions (
make-exercise-repoandconfig-local-username). While this assignment pattern appears across 21 other setup.sh files in the repository, it is functionally used in only one of them (merge-conflict). Consider removing it unless there are plans to use it in the future, or document its purpose clearly.worktree/setup.ps1 (1)
1-1: The PowerShell setup already configures the local git user.The
config-local-usernamefunctionality is not missing from worktree/setup.ps1. The PowerShell version performs the same configuration inline within make-exercise-repo.ps1, which is sourced at line 1 of setup.ps1. The file already setsuser.nameto "git-katas trainer bot" anduser.emailto "[email protected]" in the exercise repository, matching the behavior of the shell version. This implementation pattern is consistent across all PowerShell setup files in the repository.Likely an incorrect or invalid review comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
worktree/setup.ps1(1 hunks)worktree/setup.sh(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
worktree/setup.sh (2)
utils/make-exercise-repo.sh (1)
make-exercise-repo(2-12)utils/make-setup.sh (1)
config-local-username(11-24)
🪛 Shellcheck (0.11.0)
worktree/setup.sh
[warning] 6-6: kata appears unused. Verify use (or export if used externally).
(SC2034)
🔇 Additional comments (3)
worktree/setup.sh (1)
10-26: Git workflow logic looks correct.The script creates an appropriate exercise environment for learning Git worktrees:
- Initial commit on master establishes a baseline
- Feature branch with two commits provides content for parallel work
- Returning to master sets up the expected starting state
The sequence matches the PowerShell counterpart and aligns with typical worktree exercise workflows.
worktree/setup.ps1 (2)
3-19: Git workflow logic looks correct.The PowerShell script mirrors the bash version's workflow effectively:
- Uses PowerShell-native cmdlets (
Set-Content,Add-Content) appropriately- Creates identical Git history: initial commit on master, feature branch with two commits
- Returns to master as expected
The implementation is consistent with the bash counterpart and provides the right starting state for the worktree exercise.
1-1: No action needed—PowerShell version already handles username configuration internally.The PowerShell script's
make-exercise-repo.ps1already sets local git username and email viagit config --local user.nameandgit config --local user.email, whereas the bash version splits this across two separate function calls (make-exercise-repo.shandconfig-local-username). The PowerShell implementation is consistent and complete as written.
|
hey @JKrag I love this repo it really helped me in my initial git journey! I'd love if you could review this at your leisure. |
|
hey @JKrag |
Add Git Worktree Lesson
This PR adds a new kata exercise for learning Git worktrees.
Summary by CodeRabbit
Documentation
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.