File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,25 @@ function split()
6060
6161function remote()
6262{
63- git remote add $1 $2 || true
63+ # 检查远程仓库是否已存在
64+ if git remote | grep -q " ^$1 $" ; then
65+ CURRENT_URL=$( git remote get-url $1 )
66+ if [ " $CURRENT_URL " != " $2 " ]; then
67+ echo " ⚠️ Warning: Remote '$1 ' exists but points to a different URL"
68+ echo " Current URL: $CURRENT_URL "
69+ echo " Expected URL: $2 "
70+ read -p " Do you want to update the remote URL? (y/n): " update_remote
71+ if [[ $update_remote == " y" || $update_remote == " Y" ]]; then
72+ echo " Updating remote URL..."
73+ git remote set-url $1 $2
74+ else
75+ echo " ❌ Operation cancelled: Remote URL mismatch"
76+ exit 1
77+ fi
78+ fi
79+ else
80+ git remote add $1 $2
81+ fi
6482}
6583
6684# 更健壮地处理git pull操作
@@ -82,4 +100,4 @@ split "backend/$COMPOSE_NAME" $COMPOSE_NAME
82100
83101TIME=$( echo " $( date +%s) - $NOW " | bc)
84102
85- printf " Execution time: %f seconds" $TIME
103+ printf " Execution time: %f seconds" $TIME
You can’t perform that action at this time.
0 commit comments