@@ -150,9 +150,38 @@ export default class flow {
150150 hugospinner . succeed ( 'Hugo site created' ) ;
151151
152152 var precommand = 'cd ' + response . directory + ' && ' ;
153- const gitspinner = ora ( 'Initializing Git' ) . start ( ) ;
154- await utils . run ( precommand + 'git init' , false )
155- gitspinner . succeed ( 'Git initialized' ) ;
153+
154+ // Check if there's an existing git repo in parent directories
155+ const existingGitRepo = utils . findGitRepoInParents ( process . cwd ( ) ) ;
156+ let skipGitInit = false ;
157+
158+ if ( existingGitRepo ) {
159+ console . log ( chalk . yellow ( '\nFound existing Git repository at: ' + existingGitRepo ) ) ;
160+ const gitChoice = await safePrompt ( {
161+ type : 'select' ,
162+ name : 'option' ,
163+ message : 'How would you like to handle Git?' ,
164+ choices : [
165+ 'Use existing repository (recommended for subdirectories)' ,
166+ 'Create new repository in ' + response . directory
167+ ]
168+ } ) ;
169+
170+ if ( ! gitChoice ) {
171+ flow . showMain ( ) ;
172+ return ;
173+ }
174+
175+ skipGitInit = gitChoice . option . includes ( 'Use existing' ) ;
176+ }
177+
178+ if ( ! skipGitInit ) {
179+ const gitspinner = ora ( 'Initializing Git' ) . start ( ) ;
180+ await utils . run ( precommand + 'git init' , false )
181+ gitspinner . succeed ( 'Git initialized' ) ;
182+ } else {
183+ console . log ( chalk . green ( '✔ Using existing Git repository' ) ) ;
184+ }
156185
157186 const blowfishspinner = ora ( 'Installing Blowfish' ) . start ( ) ;
158187 const submoduleExitCode = await utils . run ( precommand + 'git submodule add --depth 1 -b main https://github.com/nunocoracao/blowfish.git themes/blowfish' , false , true ) ;
@@ -241,9 +270,38 @@ export default class flow {
241270 hugospinner . succeed ( 'Template cloned' ) ;
242271
243272 var precommand = 'cd ' + response . directory + ' && ' ;
244- const gitspinner = ora ( 'Initializing Git' ) . start ( ) ;
245- await utils . run ( precommand + 'git init' , false )
246- gitspinner . succeed ( 'Git initialized' ) ;
273+
274+ // Check if there's an existing git repo in parent directories
275+ const existingGitRepo = utils . findGitRepoInParents ( process . cwd ( ) ) ;
276+ let skipGitInit = false ;
277+
278+ if ( existingGitRepo ) {
279+ console . log ( chalk . yellow ( '\nFound existing Git repository at: ' + existingGitRepo ) ) ;
280+ const gitChoice = await safePrompt ( {
281+ type : 'select' ,
282+ name : 'option' ,
283+ message : 'How would you like to handle Git?' ,
284+ choices : [
285+ 'Use existing repository (recommended for subdirectories)' ,
286+ 'Create new repository in ' + response . directory
287+ ]
288+ } ) ;
289+
290+ if ( ! gitChoice ) {
291+ flow . showMain ( ) ;
292+ return ;
293+ }
294+
295+ skipGitInit = gitChoice . option . includes ( 'Use existing' ) ;
296+ }
297+
298+ if ( ! skipGitInit ) {
299+ const gitspinner = ora ( 'Initializing Git' ) . start ( ) ;
300+ await utils . run ( precommand + 'git init' , false )
301+ gitspinner . succeed ( 'Git initialized' ) ;
302+ } else {
303+ console . log ( chalk . green ( '✔ Using existing Git repository' ) ) ;
304+ }
247305
248306 const blowfishspinner = ora ( 'Installing Blowfish' ) . start ( ) ;
249307 await utils . directoryDelete ( response . directory + '/themes/blowfish' )
0 commit comments