git 拉取某個分支到本地
比如我想拉取dev到本地來
通常情況下,我會先直接嘗試:git clone https://github.com/XXXX/nothing2/tree/dev.git
會報這種錯誤:fatal: repository 'https://github.com/XXXX/nothing2/tree/dev.git/' not found,
顯然分支並不是有效的repository地址
於是嘗試另外的方法
首先自己要與origin master建立連線:git remote add origin [email protected]:XXXX/nothing2.git
然後我們才能切換到其中某個子分支:git checkout -b dev origin/dev
可能會報這種錯誤: fatal: Cannot update paths and switch to branch 'dev' at the same time. Did you intend to checkout 'origin/dev' which can not be resolved as commit?
原因是你本地並沒有dev這個分支,這時你可以用git branch -a 命令來檢視本地是否具有dev分支
我們需要:git fetch origin dev 命令來把遠端分支拉到本地
然後使用:git checkout -b dev origin/dev
最後使用:git pull origin dev就可以把某個分支上的內容都拉取到本地了
--------------------- 本文來自 奔跑-起點 的CSDN 部落格 ,全文地址請點選:https://blog.csdn.net/bbaiggey/article/details/53505136?utm_source=copy