mirror of
https://gitlab.com/ProcyonLotor/vrchat-template.git
synced 2026-08-25 10:43:53 +05:00
Added shell scripts for repository reset
This commit is contained in:
33
repo-reset.cmd
Normal file
33
repo-reset.cmd
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
@ECHO OFF
|
||||||
|
TITLE Reset Unity Project repo
|
||||||
|
SETLOCAL
|
||||||
|
|
||||||
|
CD "%~dp0"
|
||||||
|
git rev-parse --is-inside-work-tree >NUL || GOTO die
|
||||||
|
|
||||||
|
FOR /F "delims=" %%x IN ('git rev-parse --abbrev-ref "@{u}" 2^>NUL') DO SET "upstream=%%x"
|
||||||
|
IF NOT DEFINED upstream (
|
||||||
|
ECHO *** ERROR: No upstream is configured for current branch
|
||||||
|
GOTO die
|
||||||
|
)
|
||||||
|
|
||||||
|
ECHO Going to reset current branch to: %upstream%
|
||||||
|
ECHO *** WARNING: All local changes and commits will be lost!
|
||||||
|
|
||||||
|
ECHO.
|
||||||
|
CHOICE /M "Execute"
|
||||||
|
IF %ERRORLEVEL% NEQ 1 (
|
||||||
|
ECHO Aborting reset...
|
||||||
|
) ELSE (
|
||||||
|
git fetch --all || GOTO die
|
||||||
|
git reset --hard "%upstream%" || GOTO die
|
||||||
|
ECHO Done.
|
||||||
|
)
|
||||||
|
|
||||||
|
:end
|
||||||
|
PAUSE
|
||||||
|
EXIT /B 0
|
||||||
|
|
||||||
|
:die
|
||||||
|
PAUSE
|
||||||
|
EXIT /B %ERRORLEVEL%
|
||||||
24
repo-reset.sh
Executable file
24
repo-reset.sh
Executable file
@@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
cd "$(dirname "$(readlink -f "$0")")"
|
||||||
|
git rev-parse --is-inside-work-tree >/dev/null
|
||||||
|
|
||||||
|
upstream="$(git rev-parse --abbrev-ref "@{u}" 2>/dev/null || true)"
|
||||||
|
if [ -z "$upstream" ]; then
|
||||||
|
echo "*** ERROR: No upstream is configured for current branch"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Going to reset current branch to: ${upstream}"
|
||||||
|
echo "*** WARNING: All local changes and commits will be lost!"
|
||||||
|
|
||||||
|
printf "\nExecute [Y,N]?"; read -r yn
|
||||||
|
if [ "$yn" = "${yn#[Yy]}" ]; then
|
||||||
|
echo "Aborting reset..."
|
||||||
|
else
|
||||||
|
git fetch --all
|
||||||
|
git reset --hard "$upstream"
|
||||||
|
echo "Done."
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
Reference in New Issue
Block a user