git: 替换remote origin

查看远程origin地址:

git remote -v

 

删除现有的origin地址 或 更新名称:

git remote remove origin
git remote rename origin 新名称

 

添加新的origin地址(新建的代码托管地址):

git remote add origin 远程地址

 

pull远程代码:

git branch --set-upstream-to=origin/<branch> master
git pull origin master --allow-unrelated-histories

 

正常提交本地代码到新origin地址

 有多个远程地址时,提交之后需要push多个仓库:

git pull 默认仓库
git pull 远程仓库名称 分支名称
git add .
git commit -m ""
git push 默认仓库 
git push 远程仓库名称 分支名称

 

 修改默认提交仓库

git config --global user.name 你的英文名
git config --global user.email 你的邮箱
git config --global push.default simple current
must be one of nothing, matching, simple, upstream or current
git config branch.master.remote 默认提交的仓库名称

 

posted @ 2021-02-27 09:32  Nyan  阅读(3807)  评论(0编辑  收藏  举报