使用git下载GitHub项目中指定分支代码

一般来讲

git clone -b <branch> <remote_repo>

以下面的内容为例

git clone -b release https://github.com/OpenImageIO/oiio.git

此处的 -b 表示要从branch上git clone,release 表示具体的分支名称,https://github.com/OpenImageIO/oiio.git 是code所在源码的git仓库地址,是所有该项目中分支共用的地址(不存在某个branch仓库地址的说法)。


根据说明:

The release branch is very stable and promises to never break back-compatibility with APIs or linkage within that release. The master branch is where new development happens; it tends to be very solid code but its APIs may change at any time.

我找到自己想下载的代码该代码位于 <>code 下面的 Branch: release 中,如下图所示,前面有  标志的即是当前选择的分支。

图1-1 在左侧Branches列表里找到自己需要的分支

然后复制git仓库地址,如下图所示。

复制git仓库地址

最后在终端输入 git clone -b release https://github.com/OpenImageIO/oiio.git 回车即可得到所需分支。

猜你喜欢

转载自www.cnblogs.com/phillee/p/10610687.html