问题
将本地分支与远程分支关联起来
操作
- 创建本地分支:dev
- 提交并关联远程分支(远程无dev分支)
命令
git branch -a
git checkout -b dev
git push --set-upstream origin dev
git branch -a
将远程分支拉到本地
假如本地分支不存在
git checkout -b dev2 origin/dev2
如果提示:
fatal: Cannot update paths and switch to branch 'dev2' at the same time.
Did you intend to checkout 'origin/dev2' which can not be resolved as commit?
表示拉取不成功。我们需要先执行:
git fetch
再执行
git checkout -b dev2 origin/dev2