Git多人协作

1.克隆远程仓库的指定分支,这里是克隆的dev分支

$ git clone -b <远程分支名> <远程仓库地址>
$ git clone -b dev http://yuanchengbo@10.79.1.167/yuanchengbo/study.git

      2.拉取远程仓库的指定分支

$ git pull <远程主机名> <远程分支名>:<本地分支名>
$ git pull origin master:master

  其他:

  • 查看远程库信息,使用git remote -v;

  • 本地新建的分支如果不推送到远程,对其他人就是不可见的;

  • 从本地推送分支,使用git push origin branch-name,如果推送失败,先用git pull抓取远程的新提交;

  • 在本地创建分支并切换到此分支:git checkout -b branch-name
  • 在本地创建和远程分支对应的分支,使用git checkout -b branch-name origin/branch-name,本地和远程分支的名称最好一致;

  • 建立本地分支和远程分支的关联,使用git branch --set-upstream branch-name origin/branch-name;

  • 从远程抓取分支,使用git pull,如果有冲突,要先处理冲突。

原文地址:https://www.cnblogs.com/bocurry/p/7766612.html