连接git仓库 将项目拉取到本地

步骤:

1. 首先,在需要拉去项目的文件夹中:git init

2.连接git仓库:git remote add origin <仓库地址>

此步骤执行完毕是没有提示的

3.拉取项目到本地: git pull

有可能会提示这个:

4. 此时,按照提示执行: git branch --set-upstream-to=origin/master master

然后,会提示:fatal: branch 'master' does not exist4,出现这个问题原因就是本地没有 master 分支导致的。

5.输入:git branch -a

查看到只有远程分支:

6.解决方式是输入:git checkout master

出现 Already on 'master' ,Branch 'master' set up to track remote branch 'master' from 'origin'.,说明已经切换到 master 上。

7. 在此输入:git branch -a

会发现已有本地分支:

8.再用:git branch -avvv 查看:

  • 【a:查看所有分支】
  • 【v:每个分支的最后一个提交(commit)】
  • 【vv:本地分支与远程分支的关联关系】

 

参考来自:git fatal: branch ‘master‘ does not exist_凯小默:树上的男爵的博客-CSDN博客