背景:
一开始做实验的时候一直都是用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
成功解决!