-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c59c89
commit 7e2b15f
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
@echo off | ||
set /p branchName="Enter the branch name to archive: " | ||
|
||
:: Check if the branch exists locally | ||
git rev-parse --verify %branchName% >nul 2>&1 | ||
if errorlevel 1 ( | ||
echo The branch '%branchName%' does not exist locally. | ||
echo Fetching the branch from the remote repository... | ||
git fetch origin %branchName%:%branchName% | ||
) | ||
|
||
:: Check if the fetch was successful | ||
git rev-parse --verify %branchName% >nul 2>&1 | ||
if errorlevel 1 ( | ||
echo Failed to fetch the branch '%branchName%'. Please check the branch name and try again. | ||
exit /b | ||
) | ||
|
||
:: Archive the branch | ||
set tagName=archive/%branchName% | ||
git tag %tagName% %branchName% | ||
git push origin %tagName% | ||
echo Branch %branchName% has been archived as %tagName%. | ||
|
||
:: Ask the user if they want to delete the branch | ||
set /p deleteBranch="Do you want to delete the branch locally and remotely? (yes/no): " | ||
if /i "%deleteBranch%"=="yes" ( | ||
git branch -d %branchName% | ||
git push origin --delete %branchName% | ||
echo Branch %branchName% has been deleted. | ||
) | ||
|
||
:: Suggest a filename for the batch file | ||
set filename=archive_git_branch_%branchName%_%date:/=-%.bat | ||
echo Suggested filename for this batch file is: %filename% | ||
:: Filename: archive_git_branch.bat | ||
|
||
@echo off | ||
set /p branchName="Enter the branch name to archive: " | ||
|
||
:: Check if the branch exists locally | ||
git rev-parse --verify %branchName% >nul 2>&1 | ||
if errorlevel 1 ( | ||
echo The branch '%branchName%' does not exist locally. | ||
echo Fetching the branch from the remote repository... | ||
git fetch origin %branchName%:%branchName% | ||
) | ||
|
||
:: Check if the fetch was successful | ||
git rev-parse --verify %branchName% >nul 2>&1 | ||
if errorlevel 1 ( | ||
echo Failed to fetch the branch '%branchName%'. Please check the branch name and try again. | ||
exit /b | ||
) | ||
|
||
:: Archive the branch | ||
set tagName=archive/%branchName% | ||
git tag %tagName% %branchName% | ||
git push origin %tagName% | ||
echo Branch %branchName% has been archived as %tagName%. | ||
|
||
:: Ask the user if they want to delete the branch | ||
set /p deleteBranch="Do you want to delete the branch locally and remotely? (yes/no): " | ||
if /i "%deleteBranch%"=="yes" ( | ||
git branch -d %branchName% | ||
git push origin --delete %branchName% | ||
echo Branch %branchName% has been deleted. | ||
) |