更改远程仓库

#!/bin/bash

type=linux
root=`pwd`
svx=${root##*/}

if [ "$type" != "linux" ] && [ "$type" != "qnx" ]; then
    echo -e "\033[0;32mUsage:\033[0;0m \n\t./updateUrl linux"
    echo -e "\033[0;32mUsage:\033[0;0m \n\t./updateUrl qnx"
    exit
fi

if [ "$svx" != "svp" ] && [ "$svx" != "sva" ]; then
    echo -e "\033[0;31mERROR:\033[0;0m 请在svp-repo/svp或sva-repo/sva目录下运行脚本"
    exit
fi

git remote set-url origin git@scm-gitlab:$svx/$type/cbb/$svx-repo.git
for m in $root/*; do
if [ -d $m/.git ]; then
    cd $m
    echo -e "\033[0;36mINFO:\033[0;0m update ${m##*/} url to git@scm-gitlab:$svx/$type/cbb/${m##*/}.git"
    git remote set-url origin git@scm-gitlab:$svx/$type/cbb/${m##*/}.git
fi
done

https://www.jb51.net/article/127941.htm

方法一 通过命令直接修改远程地址

进入git_test根目录

git remote 查看所有远程仓库, git remote xxx 查看指定远程仓库地址

方法二 通过命令先删除再添加远程仓库

进入git_test根目录
git remote 查看所有远程仓库, git remote xxx 查看指定远程仓库地址
git remote rm origin

方法三 直接修改配置文件

进入git_test/.git
vim config
 
[core]
repositoryformatversion = 0
filemode = true
logallrefupdates = true
precomposeunicode = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
posted @ 2019-10-09 09:21  于光远  阅读(784)  评论(0编辑  收藏  举报