Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to switch between GitHub branches in Google Colab

I have cloned a GitHub repository in Google Colab using !git clone ... but now I want to switch to another branch I have been working on. Seems like GitHub doesn't provide a unique clone link for different branches and colab doesn't allow !git checkout ... commands. Is there any way I can change branches in colab?

like image 781
Tirth Patel Avatar asked May 12 '26 23:05

Tirth Patel


1 Answers

Yes, for example:

!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'
like image 60
jakevdp Avatar answered May 14 '26 12:05

jakevdp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!