首页 > 解决方案 > 如何在 Google Colab 中的 GitHub 分支之间切换

问题描述

我已经在 Google Colab 中克隆了一个 GitHub 存储库,!git clone ...但现在我想切换到我一直在研究的另一个分支。似乎 GitHub 没有为不同的分支提供唯一的克隆链接,而 colab 不允许使用!git checkout ...命令。有什么办法可以更改 colab 中的分支吗?

标签: gitgoogle-colaboratory

解决方案


是的,例如:

!git clone https://github.com/googlecolab/colabtools.git
!cd colabtools && git checkout incoming
Cloning into 'colabtools'...
remote: Enumerating objects: 125, done.
remote: Counting objects: 100% (125/125), done.
remote: Compressing objects: 100% (125/125), done.
remote: Total 1580 (delta 58), reused 67 (delta 0), pack-reused 1455
Receiving objects: 100% (1580/1580), 466.90 KiB | 861.00 KiB/s, done.
Resolving deltas: 100% (887/887), done.
Branch 'incoming' set up to track remote branch 'incoming' from 'origin'.
Switched to a new branch 'incoming'

推荐阅读