GitHubのリポジトリをgoogle colabにcloneする方法
下記の手順です。
- google drive をマウントする
google_drive.py
from google.colab import drive
drive.mount('/content/drive')
- git clone で指定した場所にリポジトリを作成する
git_clone.py
import shutil
import os
# カレントディレクトリを変更する
os.chdir('/content/drive/My Drive')
cur_dir = os.getcwd()
git_name = '/MongoDB_PyMongo_Tutorial'
git_folder = cur_dir + git_name
# 存在すれば削除する
if os.path.exists(git_folder):
shutil.rmtree(git_folder)
# クローンする
!git clone https://github.com/Giffy/MongoDB_PyMongo_Tutorial.git