Skip to content

docs(advanced-git): warn about bare-name worktree resolution trap#32

Merged
CybotTM merged 1 commit into
mainfrom
docs/worktree-bare-name-gotcha
Apr 22, 2026
Merged

docs(advanced-git): warn about bare-name worktree resolution trap#32
CybotTM merged 1 commit into
mainfrom
docs/worktree-bare-name-gotcha

Conversation

@CybotTM

@CybotTM CybotTM commented Apr 22, 2026

Copy link
Copy Markdown
Member

Small retrospective contribution from netresearch/t3x-nr-image-optimize session.

What

Added a warning block to the bare-worktree-layout section explaining that git -C .bare worktree add <name> <branch> resolves <name> relative to the .bare/ directory, not the current working directory. A bare name without a prefix creates .bare/feature-x — a repo-inside-a-repo mess that violates the sibling-layout convention the skill already documents (and drew real user frustration during today's session).

Why

The skill already shows the right pattern (../feature-x) in all its examples, but doesn't explicitly warn about what happens if you forget the prefix. Hit this three times today before remembering to use absolute paths. The existing examples are correct; this just makes the failure mode explicit so a future reader doesn't have to rediscover it.

Content

  • Wrong vs. right invocation patterns (feature-x vs. ../feature-x / absolute)
  • Recovery for misplaced worktrees using worktree move with absolute paths (same trap applies to move, so the recovery command must use absolute paths)

Test plan

  • Markdown renders cleanly
  • Fits inline where the bare-layout docs already live (no new section, just a warning block after the existing examples)

Copilot AI review requested due to automatic review settings April 22, 2026 00:04
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions

github-actions Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an explicit warning to the “Bare-Worktree Project Layout (Recommended)” docs to prevent accidentally creating worktrees inside the bare repo when using git -C .bare.

Changes:

  • Document the path-resolution trap when running git -C .bare worktree add <path> <branch> with a bare (non-prefixed) <path>.
  • Provide “wrong vs right” examples using sibling-relative (../...) and absolute paths.
  • Add a recovery section describing how to move a mistakenly created worktree.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread skills/git-workflow/references/advanced-git.md Outdated
@CybotTM CybotTM force-pushed the docs/worktree-bare-name-gotcha branch from dddb763 to 551b90f Compare April 22, 2026 00:07
@CybotTM CybotTM requested a review from Copilot April 22, 2026 00:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a targeted warning to the advanced Git workflow docs to prevent accidental creation of a worktree directory inside the bare repo when using git -C .bare worktree add, and documents a safe recovery path.

Changes:

  • Documented the -C .bare path-resolution trap (feature-x vs ../feature-x / absolute paths).
  • Added a recovery recipe using git worktree move with absolute paths (and an alternative safe invocation pattern).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread skills/git-workflow/references/advanced-git.md Outdated
Comment thread skills/git-workflow/references/advanced-git.md Outdated
Comment thread skills/git-workflow/references/advanced-git.md Outdated
`git -C .bare worktree add <name> <branch>` resolves <name> relative to
the `.bare/` directory, not the current working directory. A bare name
without a prefix (e.g. `feature-x` instead of `../feature-x`) creates
`.bare/feature-x` — a repo-inside-a-repo mess that confuses tools
(lockfile scanners, release scripts, IDE workspace detection) and
violates the sibling-layout convention the skill already documents.

Add a warning block with the wrong vs right patterns, and a recovery
note showing how to move a misplaced worktree with absolute paths
(`worktree move` inherits the same relative-path trap, so the recovery
command must use absolute paths too).

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
@CybotTM CybotTM force-pushed the docs/worktree-bare-name-gotcha branch from 551b90f to 18a83f5 Compare April 22, 2026 00:34
@CybotTM CybotTM requested a review from Copilot April 22, 2026 00:44
@CybotTM CybotTM merged commit 06237e8 into main Apr 22, 2026
14 checks passed
@CybotTM CybotTM deleted the docs/worktree-bare-name-gotcha branch April 22, 2026 00:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an explicit warning to the advanced Git “bare-worktree project layout” documentation about a common git -C .bare worktree add trap where a bare path (e.g., feature-x) is resolved inside .bare/, creating an unintended in-bare worktree.

Changes:

  • Documented wrong vs right worktree add invocation patterns (feature-x vs ../feature-x / absolute path).
  • Added guidance on creating a new branch during worktree add via -b ... <start>.
  • Added recovery instructions for moving a mistakenly created in-bare worktree.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +376 to +378
(Alternatively, drop `-C .bare` and run from the repo parent; then the
source `.bare/feature-x` resolves against that parent rather than
against `.bare/`.)
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.

2 participants