7

I usually use this to clone a github repo in colab

!git clone https://github.com/user/repo.git

But say I want to clone a specific branch of the repo. I tried

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

But I get an error

fatal: repository 'https://github.com/user/repo/tree/branch.git/' not found

Mohammad Ravanbakhsh
  • 2,244
  • 1
  • 15
  • 26
SantoshGupta7
  • 5,607
  • 14
  • 58
  • 116
  • 1
    Possible duplicate of [How do I clone a single branch in Git?](https://stackoverflow.com/questions/1778088/how-do-i-clone-a-single-branch-in-git) – Rob Kwasowski Jul 21 '19 at 04:01

1 Answers1

10

Try this:

!git clone -b branch_name https://github.com/user/repo.git

replace branch_name with the name of branch you want to clone

Cao Minh Vu
  • 1,900
  • 1
  • 16
  • 21