Skip to content

[Bug?]: yarn init should not create a new git repo when already inside a git repo #6846

@Yvem

Description

@Yvem

Self-service

  • I'd be willing to implement a fix

Describe the bug

yarn init -2 created a git repo inside my git repo :-/

To reproduce

Steps:

  • I created a fresh git repo on GitHub
  • I clone it on my machine, enabled corepack
  • I created a subfolder and invoked yarn init -2 inside it (100% sure yarn v4 was invoked, I got clear messages about version 4.x.y)
    -🪲 yarn created a git repo inside my git repo

Environment

System:
    OS: macOS 15.5
    CPU: (8) arm64 Apple M2
  Binaries:
    Node: 24.4.0 - /private/var/folders/dv/_cxsbt9x6xj5695nk5qgz1f00000gp/T/xfs-1d9c87b5/node
    Yarn: 4.9.2 - /private/var/folders/dv/_cxsbt9x6xj5695nk5qgz1f00000gp/T/xfs-1d9c87b5/yarn
    npm: 11.4.2 - ~/.nvm/versions/node/v24.4.0/bin/npm

Additional context

A quick check of not being already in a git repo should be performed. Aside my example above, creating a new package/workspace in a monorepo would face the same issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions