feat: git remote change script doesn't need originial auth method
This commit is contained in:
1 file changed
+6
-9
@@ -2,22 +2,19 @@
|
||||
|
||||
set -e
|
||||
|
||||
origin=$(git remote show origin)
|
||||
origin=$(git remote get-url origin)
|
||||
git_branch=$(git branch | grep '*' | tr -d ' *')
|
||||
if [[ $(echo "$origin" | awk -e '/https/') != "" ]]; then
|
||||
remote=$(git remote show origin | awk -e '/Fetch/' | cut -d ":" -f 3)
|
||||
git_host=$(echo "$remote" | cut -d "/" -f 3)
|
||||
git_repo=$(echo "$remote" | cut -d "/" -f 4-)
|
||||
git_branch=$(echo "$origin" | awk -e '/HEAD/' | cut -d ":" -f 2 | tr -d ' ')
|
||||
git_host=$(echo "$origin" | cut -d "/" -f 3)
|
||||
git_repo=$(echo "$origin" | cut -d "/" -f 4-)
|
||||
git remote remove origin
|
||||
git remote add origin git@$git_host:/$git_repo
|
||||
git fetch
|
||||
git branch --set-upstream-to=origin/$git_branch $git_branch
|
||||
echo "Updated to SSH url git@$git_host:/$git_repo, for branch $git_branch"
|
||||
else
|
||||
remote=$(git remote show origin | awk -e '/Fetch/' | cut -d ":" -f 2-3)
|
||||
git_host=$(echo "$remote" | cut -d "@" -f 2 | cut -d ":" -f 1)
|
||||
git_repo=$(echo "$remote" | cut -d ":" -f 2 | cut -d "/" -f 2-)
|
||||
git_branch=$(echo "$origin" | awk -e '/HEAD/' | cut -d ":" -f 2 | tr -d ' ')
|
||||
git_host=$(echo "$origin" | cut -d "@" -f 2 | cut -d ":" -f 1)
|
||||
git_repo=$(echo "$origin" | cut -d ":" -f 2 | cut -d "/" -f 2-)
|
||||
git remote remove origin
|
||||
git remote add origin https://$git_host/$git_repo
|
||||
git fetch
|
||||
|
||||
Reference in new issue
Block a user