@@ -276,7 +276,14 @@ if [ "$DRY_RUN" = true ]; then
276276 fi
277277
278278 if [ " $INIT_VERSION " = true ]; then
279- echo " git tag $VERSION_TAG && git push origin $VERSION_TAG "
279+ if [ " $INIT_README " = true ] || [ -n " $ADD_LICENSE " ] || [ -n " $ADD_GITIGNORE " ]; then
280+ echo " git tag $VERSION_TAG && git push origin $VERSION_TAG "
281+ else
282+ echo " # Create empty initial commit (empty repo)"
283+ echo " git commit --allow-empty -m 'chore: initial repository setup'"
284+ echo " git push -u origin main"
285+ echo " git tag $VERSION_TAG && git push origin $VERSION_TAG "
286+ fi
280287 fi
281288
282289 if [ " $CLONE_AFTER " = true ]; then
@@ -343,11 +350,33 @@ if [ "$INIT_VERSION" = true ]; then
343350 if [ " $INIT_README " = true ] || [ -n " $ADD_LICENSE " ] || [ -n " $ADD_GITIGNORE " ]; then
344351 create_version_tag " $FULL_NAME " " $VERSION_TAG " " $CLONE_DIR "
345352 else
353+ # Empty repo - create initial commit first
346354 echo " "
347- echo -e " ${YELLOW} Note: Version tag requires at least one commit.${NC} "
348- echo " Use --init, --license, or --gitignore to create initial commit,"
349- echo " or create the tag manually after your first commit:"
350- echo " git tag $VERSION_TAG && git push origin $VERSION_TAG "
355+ echo -e " ${CYAN} Creating initial commit for version tag...${NC} "
356+
357+ TEMP_DIR=$( mktemp -d)
358+ cd " $TEMP_DIR "
359+
360+ git init --quiet
361+ git remote add origin " https://github.com/$FULL_NAME .git"
362+
363+ # Configure git for this commit
364+ git config user.email " devtools@bauer-group.com"
365+ git config user.name " DevTools"
366+
367+ # Create empty initial commit
368+ git commit --quiet --allow-empty -m " chore: initial repository setup"
369+ git branch -M main
370+ git push -u origin main --quiet
371+
372+ # Now create the tag
373+ git tag " $VERSION_TAG "
374+ git push origin " $VERSION_TAG " --quiet
375+
376+ cd - > /dev/null
377+ rm -rf " $TEMP_DIR "
378+
379+ echo -e " ${GREEN} Initial commit and tag $VERSION_TAG created${NC} "
351380 fi
352381fi
353382
0 commit comments