本地创建仓库后如何与远程仓库关联

162 阅读1分钟

1、先在本地仓库初始化 git 仓库

git init

2、 然后关联远程仓库(这里必须使用 ssh 关联,使用 https 时会提示你不支持。请去掉 <>

git remote add <仓库名字> <仓库 ssh 地址>

3、接下来先拉去远程仓库的代码

  git pull <仓库名字> main --allow-unrelated-histories

4、最后推送本地代码到远程仓库

git push --set-upstream <仓库名字> main

之后提交代码就可以愉快的使用 git push, git pull 了,也可以使用 source tree 等工具。