Reputation: 243
I followed the steps given in this Medium tutorial on google colab and then tried to clone a git repository but I cannot see the repository anywhere in my drive.
The following image is the code snippet I used which is exactly the same as that from the Medium tutorial:
How can I add a path to my Google Drive in Google Colab?
Upvotes: 6
Views: 20098
Reputation: 171
To mount google drive on google Colab just use these commands:
from google.colab import drive
drive.mount('/content/drive')
It would need an authentication process. Do whatever it needs (open the link and copy the key)
Now you have mounted your google drive in /content/drive/
directory in your google Colab machine.
To clone a git repository, first set your current directory as a path in /content/drive/
, then just clone the git repository. Like below:
path_clone = "/content/drive/my_project"
%cd path_clone
!git clone <Git project URL address>
Now you would have the cloned Git project in my_projects
folder in your Google Drive (which is also connected to your Google Colab runtime machine)
Upvotes: 7
Reputation: 1906
Just do cd drive
(without !
) or %cd drive
.
See cd vs !cd vs %cd in IPython.
Upvotes: 0
Reputation: 1193
Adjust ur path where you git clone. try adding drive folder to path
import os
os.chdir("drive")
Upvotes: 0