5

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
  • 1,232
  • 1
  • 8
  • 24
SantoshGupta7
  • 4,955
  • 5
  • 42
  • 92
  • 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

7

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,800
  • 1
  • 14
  • 20