feat: 娣诲姞澶氫釜鏂板姛鑳藉拰淇 - 鍖呮嫭鐢ㄦ埛绠$悊銆佹暟鎹簱杩佺Щ銆丟it鎺ㄩ€佸伐鍏风瓑
This commit is contained in:
79
test_git_push.bat
Normal file
79
test_git_push.bat
Normal file
@@ -0,0 +1,79 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
echo ========================================
|
||||
echo Git推送测试脚本
|
||||
echo ========================================
|
||||
echo.
|
||||
|
||||
:: 检查Git状态
|
||||
echo [1] 检查Git状态...
|
||||
git status --porcelain >nul 2>&1
|
||||
if %errorlevel% neq 0 (
|
||||
echo Git未初始化
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo Git状态正常
|
||||
echo.
|
||||
|
||||
:: 获取当前分支
|
||||
echo [2] 获取当前分支...
|
||||
set current_branch=
|
||||
for /f "tokens=*" %%b in ('git branch --show-current 2^>nul') do set current_branch=%%b
|
||||
|
||||
if "!current_branch!"=="" (
|
||||
echo 无法获取当前分支,使用默认分支main
|
||||
set current_branch=main
|
||||
) else (
|
||||
echo 当前分支: !current_branch!
|
||||
)
|
||||
echo.
|
||||
|
||||
:: 检查远程仓库
|
||||
echo [3] 检查远程仓库...
|
||||
git remote -v
|
||||
if %errorlevel% neq 0 (
|
||||
echo 未配置远程仓库
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo.
|
||||
|
||||
:: 尝试推送
|
||||
echo [4] 尝试推送到远程...
|
||||
echo 分支: !current_branch!
|
||||
echo.
|
||||
|
||||
git push origin !current_branch! 2>&1
|
||||
if %errorlevel% equ 0 (
|
||||
echo.
|
||||
echo 推送成功!
|
||||
) else (
|
||||
echo.
|
||||
echo 推送失败
|
||||
echo.
|
||||
echo 可能的原因:
|
||||
echo 1. 远程分支不存在,尝试设置上游...
|
||||
git push -u origin !current_branch! 2>&1
|
||||
if %errorlevel% equ 0 (
|
||||
echo 推送成功(已设置上游)!
|
||||
) else (
|
||||
echo 推送仍然失败
|
||||
echo.
|
||||
echo 请检查:
|
||||
echo - 网络连接
|
||||
echo - 认证配置(SSH密钥或Token)
|
||||
echo - 远程仓库地址
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
echo.
|
||||
echo ========================================
|
||||
echo 测试完成
|
||||
echo ========================================
|
||||
pause
|
||||
|
||||
Reference in New Issue
Block a user