# create-gitee **Repository Path**: nodets/create-gitee ## Basic Information - **Project Name**: create-gitee - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-09-10 - **Last Updated**: 2025-09-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # create-gitee [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) `create-gitee` 是一个命令行工具,用于快速初始化 Git 仓库并推送到 Gitee(码云)。通过简单的交互式提示,您可以完成从初始化 Git 仓库到推送代码的所有步骤。 ## 功能特性 - 自动生成 `.gitignore` 文件(如果不存在)。 - 支持交互式初始化 Git 仓库 (`git init`)。 - 支持交互式将文件添加到暂存区 (`git add .`)。 - 支持交互式提交代码 (`git commit`)。 - 支持设置远程仓库地址 (`git remote add origin`)。 - 支持将代码推送到指定分支 (`git push -u origin `)。 - 提供友好的命令行提示和错误处理。 - **跨平台支持**:自动检测操作系统并生成适用于 Windows(PowerShell)和 Unix/Linux 的 Git 命令。 - **直接执行支持**:通过 `npm init gitee` 或 `npm create gitee` 直接运行工具。 ## 安装与使用 ### 直接执行 ```bash npm init gitee ``` 或 ```bash npm create gitee ``` ## 使用说明 运行工具后,按照提示完成以下步骤: 1. **初始化 Git 仓库** 工具会询问是否执行 `git init`。输入 `y` 或 `yes` 确认。 2. **将文件添加到暂存区** 工具会询问是否执行 `git add .`。输入 `y` 或 `yes` 确认。 3. **提交代码** 输入提交信息,默认值为 `Initial commit`。 4. **设置远程仓库地址** 输入您的 Gitee 仓库地址。 5. **设置分支名称** 输入目标分支名称,默认值为 [main](file://d:\hub\代码测试\proj4ts\create-gitee\src\index.ts#L116-L192)。 6. **推送代码** 工具会询问是否执行 `git push`。输入 `y` 或 `yes` 确认。 完成后,工具将显示成功消息并退出。 ## 示例 ```bash $ npm init gitee 欢迎使用create-gitee - 快速初始化Git仓库并推送到Gitee 已创建.gitignore文件 是否执行git init? (默认: y): y git init 执行成功 是否执行git add .? (默认: y): y git add . 执行成功 请输入commit备注信息 (默认: Initial commit): First commit git commit 执行成功 请输入Git仓库地址: https://gitee.com/your-repo.git 请输入分支名称 (默认: main): main git remote 添加成功 是否执行git push到main分支? (默认: y): y git push 到main分支成功 操作完成! ``` ## 跨平台支持 工具会自动检测操作系统并生成适合的 Git 命令: - **Windows**:使用 PowerShell 命令。 - **非 Windows**:使用 Unix/Linux Shell 命令。 例如,以下脚本被添加到 [package.json](file://d:\hub\代码测试\proj4ts\create-gitee\package.json) 中: ```json "scripts": { "git": "powershell -Command \"$msg = Read-Host 'Enter commit message'; git add .; git commit -m \\\"$msg\\\"; git push\"" } ```