-
-
Save niyari/1862c2fd97f4b3e99381df55f742a027 to your computer and use it in GitHub Desktop.
Gitのリモートmainブランチを更新する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set GITOPTIONS=-c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks | |
set GITUPSTREAM=main | |
set GITLOCAL=main | |
set GITORIGIN=main | |
cd %1 | |
echo ... try stash | |
git stash -u | findstr "Saved working directory" | |
if not ERRORLEVEL 1 ( | |
echo ... use stash | |
set GIT_STASH=1 | |
) else ( | |
echo ... skip stash | |
) | |
:GITPULL | |
git checkout %GITLOCAL% | |
git %GITOPTIONS% fetch --no-tags upstream | |
git %GITOPTIONS% pull upstream %GITUPSTREAM%:%GITLOCAL% | findstr "fatal:" | |
if ERRORLEVEL 1 goto GITPUSH | |
:PULLERROR | |
git checkout - | |
if defined GIT_STASH ( | |
echo ... stash pop | |
git stash pop --index | |
) | |
echo pull error | |
exit /b 1 | |
:GITPUSH | |
git %GITOPTIONS% push --tags --set-upstream origin %GITLOCAL%:%GITORIGIN% | |
git checkout - | |
if defined GIT_STASH ( | |
echo ... stash pop | |
git stash pop --index | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment