feat: 快速提交 - 周一 2025/09/22 13:18:51.04

This commit is contained in:
赵杰 Jie Zhao (雄狮汽车科技)
2025-09-22 13:18:51 +01:00
parent 91a86a1f4f
commit 8176caa338
3 changed files with 95 additions and 7 deletions

View File

@@ -27,9 +27,20 @@ if /i "%confirm%" neq "y" (
exit /b 0
)
:: 添加所有更改
:: 检查是否有更改需要提交
echo.
echo [2/4] 添加所有更改到暂存区...
echo [2/4] 检查更改状态...
git diff --quiet && git diff --cached --quiet
if %errorlevel% equ 0 (
echo 没有检测到任何更改,无需提交
echo.
echo ✅ 工作区干净,无需推送
pause
exit /b 0
)
:: 添加所有更改
echo 添加所有更改到暂存区...
git add .
if %errorlevel% neq 0 (
echo ❌ 添加文件失败
@@ -152,6 +163,16 @@ echo [4/4] 推送到远程仓库...
git push origin main
if %errorlevel% neq 0 (
echo ❌ 推送失败
echo 💡 可能的原因:
echo - 网络连接问题
echo - 远程仓库权限不足
echo - 分支冲突
echo - 需要先拉取远程更改
echo.
echo 🔧 建议解决方案:
echo 1. 检查网络连接
echo 2. 运行: git pull origin main
echo 3. 重新运行推送脚本
pause
exit /b 1
)

View File

@@ -4,6 +4,14 @@ setlocal enabledelayedexpansion
echo 🚀 TSP智能助手 - 快速推送
echo.
:: 检查Git状态
git status --porcelain >nul 2>&1
if %errorlevel% neq 0 (
echo ❌ Git未初始化或不在Git仓库中
pause
exit /b 1
)
:: 检查是否有参数
if "%1"=="" (
:: 智能生成提交信息
@@ -97,15 +105,48 @@ if "%1"=="" (
echo 📝 提交信息: %commit_msg%
echo.
:: 执行推送
git add . && git commit -m "%commit_msg%" && git push origin main
:: 检查是否有更改需要提交
git diff --quiet && git diff --cached --quiet
if %errorlevel% equ 0 (
echo 没有检测到任何更改,无需提交
echo.
echo ✅ 工作区干净,无需推送
pause
exit /b 0
)
:: 执行推送
echo.
echo 📤 开始推送流程...
echo 📝 提交信息: %commit_msg%
git add .
if %errorlevel% neq 0 (
echo ❌ 添加文件失败
pause
exit /b 1
)
git commit -m "%commit_msg%"
if %errorlevel% neq 0 (
echo ❌ 提交失败
pause
exit /b 1
)
git push origin main
if %errorlevel% equ 0 (
echo.
echo ✅ 推送完成!
echo 📊 最新提交:
git log --oneline -1
) else (
echo.
echo ❌ 推送失败,请检查错误信息
echo 💡 可能的原因:
echo - 网络连接问题
echo - 远程仓库权限不足
echo - 分支冲突
)
echo.

View File

@@ -175,12 +175,32 @@ function Test-PreCommit {
### 常见问题
1. **PowerShell执行策略错误**
1. **"nothing to commit, working tree clean" 错误**
```
原因: 工作区没有未提交的更改
解决: 脚本已自动检测并跳过推送,这是正常行为
```
2. **推送失败 (Push failed)**
```
可能原因:
- 网络连接问题
- 远程仓库权限不足
- 分支冲突
- 需要先拉取远程更改
解决方案:
1. 检查网络连接
2. 运行: git pull origin main
3. 重新运行推送脚本
```
3. **PowerShell执行策略错误**
```powershell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
```
2. **Git认证失败**
4. **Git认证失败**
```bash
# 检查远程仓库配置
git remote -v
@@ -189,12 +209,18 @@ function Test-PreCommit {
git config --global credential.helper store
```
3. **编码问题**
5. **编码问题**
```bash
# 确保控制台支持UTF-8
chcp 65001
```
6. **重复使用脚本报错**
```
原因: 工作区已干净,无需再次推送
解决: 脚本已优化,会自动检测并跳过
```
### 错误代码说明
- `退出代码 0`: 成功