40 lines
892 B
Bash
40 lines
892 B
Bash
#!/bin/bash
|
|
|
|
# Migrate Git repository to new remote target
|
|
# Parameters:
|
|
# $1 - Original repository URL (OURL)
|
|
# $2 - Repository name (RepoName)
|
|
# Returns:
|
|
# 0 - Success (all operations completed)
|
|
# !=0 - Failure (original git clone failed)
|
|
|
|
OURL=$1
|
|
RepoName=$2
|
|
TARGET=ssh://git@git.pyer.club:2222/SixMeta
|
|
|
|
# Clone original repository with shallow depth
|
|
git clone --depth 1 $OURL
|
|
|
|
# Check if clone succeeded
|
|
if [ $? -eq 0 ]; then
|
|
# Navigate to repo directory
|
|
cd $RepoName
|
|
|
|
# Clean up existing git metadata
|
|
rm -rf .git
|
|
|
|
# Reinitialize git repository with master branch
|
|
git init -b master
|
|
|
|
# Stage all files and create initial commit
|
|
git add .
|
|
git commit -m "migrate init"
|
|
|
|
# Configure new remote target and push changes
|
|
git remote add origin $TARGET/$RepoName.git
|
|
git push -u origin master
|
|
|
|
# Cleanup working directory
|
|
cd ..
|
|
rm -rf $RepoName
|
|
fi |