Search code examples
pythongithubgoogle-colaboratorymount

how to mount a github repository as the current directory folder in google colab?


I am currently loading the images from my Google Drive.

But the issue is, those images are in my drive and when I share my colab notebook to others, they can't run it since it requires my authentication code to access the Drive images.

So I thought if I uploaded the data folder in a Github repository & made that repo as public will allow anyone to fetch the data (in my case images folder). Thus no authentication required to run the colab code.

I have no idea how to mount the directory to a Github repo as Google Drive.

from google.colab import drive
drive.mount('/content/drive/') # this will set my  google drive folder as the notebook directory.

Is it possible to do a similar mounting to a github repo?


Solution

  • You could clone the repository directly like this by running git in a code cell.

    !git clone https://github.com/yourusername/yourpublicrepo.git
    

    This will create a folder called yourpublicrepo.