Skip to content

Conversation

@eytanohana
Copy link

@eytanohana eytanohana commented Dec 20, 2025

Add Git Worktree Lesson

This PR adds a new kata exercise for learning Git worktrees.

Summary by CodeRabbit

  • Documentation

    • Added a comprehensive guide for using Git worktrees to work on multiple branches in separate directories.
  • New Features

    • Added scripts to provision a sample worktree exercise workflow that creates commits and a feature branch for hands-on practice.
  • Chores

    • Expanded ignore patterns to exclude exercise-related directories and files (now ignoring names starting with "exercise-").

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 20, 2025

Walkthrough

Added Git worktree documentation and two setup scripts (PowerShell and shell) that create a minimal multi-branch exercise workflow. Expanded .gitignore to also ignore paths starting with exercise- at any depth.

Changes

Cohort / File(s) Change Summary
Configuration
​.gitignore
Added ignore pattern **/exercise-* to exclude any file or directory whose name begins with exercise- at any depth.
Documentation
worktree/README.md
New README describing Git worktree setup, step-by-step workflow, common commands, and notes on directory placement and ignore patterns.
Setup scripts
worktree/setup.ps1, worktree/setup.sh
New scripts that initialize a worktree exercise by creating an initial commit on master, creating a feature branch, making commits on feature, and switching back to master. Scripts perform sequential Git and file operations without explicit error handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify shell and PowerShell command correctness and relative paths (e.g., ..\utils\make-exercise-repo.ps1, script shebangs/permissions).
  • Confirm the .gitignore pattern **/exercise-* behaves as intended in target Git versions and does not unintentionally ignore needed files.
  • Ensure README instructions match the actual script behavior and repository layout.

Poem

🐇 I hopped between branches, light and quick,
I planted README roots and made a trick,
Two scripts to leap from master to feature,
A tidy ignore to hide each tiny creature,
Carrots for commits — a quiet, leafy pick 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Git worktree lesson' directly aligns with the PR's main objective of adding a new kata exercise for learning Git worktrees, as evidenced by the new worktree documentation and setup scripts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 50d26a3 and b8f6778.

📒 Files selected for processing (1)
  • worktree/setup.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • worktree/setup.sh

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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 checkout which works but is deprecated in favor of the more intuitive git 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 master

Note: 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 checkout which could be replaced with the more intuitive git switch command (available since Git 2.23).

🔎 Optional modernization
-git checkout -b feature
+git switch -c feature
-git checkout master
+git switch master

Note: 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

📥 Commits

Reviewing files that changed from the base of the PR and between 7d2c18f and cc426af.

📒 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-feature that will be created as siblings to the main exercise directory 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 .gitignore pattern, and the note at the end appropriately explains the placement strategy.

Note: If the setup scripts are updated to use git switch instead of git checkout, the examples in this README should be updated for consistency.

worktree/setup.sh (1)

6-6: The kata variable 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-repo and config-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-username functionality 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 sets user.name to "git-katas trainer bot" and user.email to "[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.

Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between cc426af and 50d26a3.

📒 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.ps1 already sets local git username and email via git config --local user.name and git config --local user.email, whereas the bash version splits this across two separate function calls (make-exercise-repo.sh and config-local-username). The PowerShell implementation is consistent and complete as written.

@eytanohana
Copy link
Author

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.

@eytanohana
Copy link
Author

hey @JKrag
gentle reminder :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant