fix: git remote switch script error
This commit is contained in:
1 file changed
+4
-4
@@ -4,18 +4,18 @@ set -e
|
||||
|
||||
origin=$(git remote get-url origin)
|
||||
if [[ $(echo "$origin" | awk -e '/https/') != "" ]]; then
|
||||
git_url="git@$(echo "$origin" | cut -d "/" -f 3):/$($(echo "$origin" | cut -d "/" -f 4-))"
|
||||
git_url="git@$(echo "$origin" | cut -d "/" -f 3):/$(echo "$origin" | cut -d "/" -f 4-)"
|
||||
else
|
||||
git_url="https://$(echo "$origin" | cut -d "@" -f 2 | cut -d ":" -f 1)/$(echo "$origin" | cut -d ":" -f 2 | cut -d "/" -f 2-)"
|
||||
fi
|
||||
git_branches=$(git branch | grep '*' | tr -d ' *')
|
||||
git remote remove origin
|
||||
git remote add origin $git_url
|
||||
git remote add origin "$git_url"
|
||||
git fetch
|
||||
|
||||
echo "New git url $git_url, updating branches"
|
||||
for branch in $git_branches; do
|
||||
git checkout $branch
|
||||
git branch --set-upstream-to=origin/$branch $branch
|
||||
git checkout "$branch"
|
||||
git branch --set-upstream-to=origin/$branch "$branch"
|
||||
echo "Branch $branch configured to track on origin/$branch"
|
||||
done
|
||||
Reference in new issue
Block a user