git关联远程仓库(本地库被其他远程库占用解决方案)

    xiaoxiao2022-07-13  147

    关联远程库两种方式

    1. 你现在文件夹里有项目,远程库还没建,这个情况

    先在远程库新建项目,然后git clone git@github.com:xxxx/lzzz.git 到本地文件夹空文件夹内。然后把你有的文件放进去,

    然后

    git add .

    然后

    git commit -m “你懂得"

    然后推送到云端

    git push orgin branch-name // branch-name分支名字

    完事

    2. 同样的状况,远端建完了,不想复制,不想换文件夹,就想用现在文件夹。

    进入文件夹下

    git init //初始化仓库 git remote add origin 远程仓库地址 //正常这个时候就应该好了 如果报如下的错 git remote add origin git@gitee.com:xxx/ccccc.git: remote origin already exists. // 就是本地库已经关联了一个名 origin远程库

    这个时候用这个命令查看是哪个库

    git remote -v

    显示

    我们可以删除已有远程库:

    git remote rm origin

    再关联另外的远程库(注意路径中需要填写正确的用户名):

    git remote add origin git@gitee.com:xxxxx/lc.git

    最新回复(0)