-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepository_reset.bat
More file actions
69 lines (57 loc) · 1.64 KB
/
repository_reset.bat
File metadata and controls
69 lines (57 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
@echo off
setlocal enabledelayedexpansion
rem Configurable variables
set "REPO_URL=https://github.com/bugfishtm/suitefish-cms"
set "BRANCH=main"
set "COMMIT_MSG=Initial"
rem Cool Output Messages
echo ==============================
echo Welcome to the Bugfish Git Repository Reset Script!
echo ==============================
echo WARNING: This script will:
echo 1. Delete all commit history
echo 2. Create a new initial commit with current content
echo 3. Force push to the specified branch
echo ==============================
echo CAUTION: This action is irreversible!
echo ==============================
rem Confirm the user wants to proceed
set /p "confirm=Are you sure you want to proceed? (y/n): "
if /i not "!confirm!"=="y" (
echo Operation cancelled.
pause
exit /b 1
)
rem Cool message before starting the Git commands
echo ==============================
echo Resetting repository...
echo ==============================
rem Check if Git is installed
where git >nul 2>&1
if %errorlevel% neq 0 (
echo Git is not installed or not in the system PATH.
pause
exit /b 1
)
rem Remove Git Folder
if exist ".git" (
echo Removing existing .git directory...
rmdir /s /q .git
)
rem Initialize a new Git repository
git init
rem Stage all files
git add .
rem Create a new initial commit
git commit -m "!COMMIT_MSG!"
rem Add the remote origin
git remote add origin %REPO_URL%
git checkout -b %BRANCH%
git push -f origin %BRANCH%
rem Completion message
echo ==============================
echo All done! Your repository has been reset and force pushed.
echo All previous history has been erased.
echo ==============================
pause
endlocal