From edb4c2b09a66e8281fb9e47c1f62ebbf1d6aa6e4 Mon Sep 17 00:00:00 2001 From: Chris Banford Date: Tue, 24 Jan 2023 14:31:09 +0100 Subject: [PATCH 1/3] Add a check for existing .git directory (and skip if one is found). --- packages/create-astro/src/index.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/create-astro/src/index.ts b/packages/create-astro/src/index.ts index 5b4973a12123..d0e98ada2a40 100644 --- a/packages/create-astro/src/index.ts +++ b/packages/create-astro/src/index.ts @@ -298,8 +298,16 @@ export async function main() { if (args.dryRun) { ora().info(dim(`--dry-run enabled, skipping.`)); } else if (gitResponse) { - await execaCommand('git init', { cwd }); - ora().succeed('Git repository created!'); + // Add a check to see if there is already a .git directory and skip 'git init' if yes (with msg to output) + const gitDir = './.git'; + if (fs.existsSync(gitDir)) { + ora().info( + dim('A .git directory already exists. Skipping creating a new Git repository.') + ); + } else { + await execaCommand('git init', { cwd }); + ora().succeed('Git repository created!'); + } } else { await info( 'Sounds good!', From a406fe00b2398f3b6a0b1a825c4449f07cf80ed1 Mon Sep 17 00:00:00 2001 From: Chris Banford Date: Wed, 25 Jan 2023 12:47:17 +0100 Subject: [PATCH 2/3] Changeset attempt :-) --- .changeset/try-button-rumor.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .changeset/try-button-rumor.md diff --git a/.changeset/try-button-rumor.md b/.changeset/try-button-rumor.md new file mode 100644 index 000000000000..e63c86f886d9 --- /dev/null +++ b/.changeset/try-button-rumor.md @@ -0,0 +1,4 @@ +"create-astro": patch +--- + +Check for a pre-existing .git directory and if found, skip trying to create a new one. From 8f40ee17413306cca136d95199c68b8db104110b Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Thu, 26 Jan 2023 13:43:10 -0600 Subject: [PATCH 3/3] Update .changeset/try-button-rumor.md --- .changeset/try-button-rumor.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.changeset/try-button-rumor.md b/.changeset/try-button-rumor.md index e63c86f886d9..4196822ba029 100644 --- a/.changeset/try-button-rumor.md +++ b/.changeset/try-button-rumor.md @@ -1,3 +1,4 @@ +--- "create-astro": patch ---