Git换远程仓库

博主起初用Eclipse的git插件提交,后因需提交分支改用GitBash。第一次提交到https://github.com/xxx.git仓库正常,第二次提交到https://github.com/yyy.git仓库时,按常规命令操作却仍提交到了原仓库。解决办法是先删除原有仓库映射,再重新进行remote操作。

背景:
一开始做实验的时候一直都是用Eclipse的git插件提交,但是后来有了需要提交分支的要求,于是就改用了GitBash提交。第一次提交时,提交到(https://github.com/xxx.git)仓库没有问题,到了第二次提交需要提交到(https://github.com/yyy.git)仓库,但我还是使用如下命令;
echo “# yyy” >> README.md
git init
git add README.md
git commit -m “first commit”
git remote add origin https://github.com/yyy.git
git push -u origin master
结果发现它并没有按照期望提交到https://github.com/yyy.git 仓库,反而还是提交到了https://github.com/xxx.git 仓库……

解决办法:
1、先删除原有仓库的映射
$ git remote rm origin
2、再重新remote
git commit -m “first commit”
git remote add origin https://github.com/yyy.git
git push -u origin master
成功解决!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值