如何在 Python、Colab 中克隆特定分支?

San*_*ta7 4 python git github jupyter-notebook google-colaboratory

我通常用它在colab中克隆一个github repo

!git 克隆https://github.com/user/repo.git

但是说我想克隆回购的特定分支。我试过

!git 克隆https://github.com/user/repo/tree/branch.git

但我收到一个错误

致命:未找到存储库“ https://github.com/user/repo/tree/branch.git/

小智 5

尝试这个:

!git clone -b branch_name https://github.com/user/repo.git
Run Code Online (Sandbox Code Playgroud)

将 branch_name 替换为要克隆的分支名称