32 lines
618 B
Plaintext
32 lines
618 B
Plaintext
|
#!/bin/sh
|
||
|
|
||
|
new_port=$1
|
||
|
branch_name=$(git rev-parse --abbrev-ref HEAD)
|
||
|
remote_name=$(git remote -v | awk 'NR==1{print $1}')
|
||
|
remote_url_new=$(git remote -v | awk 'NR==1{print $2}' | sed 's/:[0-9]\{2,5\}\//:'"$new_port"'\//')
|
||
|
|
||
|
echo 'Remote:'
|
||
|
git remote -v
|
||
|
echo ""
|
||
|
|
||
|
echo "Setting new remote ..."
|
||
|
git remote remove "$remote_name"
|
||
|
git remote add "$remote_name" "$remote_url_new"
|
||
|
echo "New remote set."
|
||
|
echo ""
|
||
|
|
||
|
echo "Fetching ..."
|
||
|
git fetch
|
||
|
echo "Setting branch ..."
|
||
|
git branch "--set-upstream-to=$remote_name/$branch_name" "$branch_name"
|
||
|
echo ""
|
||
|
|
||
|
echo 'Remote:'
|
||
|
git remote -v
|
||
|
echo ""
|
||
|
|
||
|
echo "Branch:"
|
||
|
git branch -v
|
||
|
|
||
|
echo ""
|