Last active
July 27, 2023 10:53
-
-
Save tabrez/00060b1bcfd136bb6d01f9cf36413bef to your computer and use it in GitHub Desktop.
work with Github repositories in Google Colab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# first cell: mount google drive folder on currect virtual machine of google colab | |
from google.colab import drive | |
drive.mount('/content/gdrive', force_remount=True) | |
%cd /content/gdrive/MyDrive/Colab Notebooks | |
!pwd && ls | |
# upload your private ssh key as id_ed25519 from left sidebar to 'Colab Notebooks' folder | |
# or modify below code to provide it in another way | |
# second cell: need to run on every new Google Colab session before interacting with Github | |
!mkdir -p /root/.ssh | |
!cp id_ed25519 /root/.ssh/ | |
!ssh-keyscan -t ed25519 github.com >> /root/.ssh/known_hosts | |
!chmod go-rwx /root/.ssh/id_ed25519 | |
!git config --global user.email "tabrez@mailbox.org" | |
!git config --global user.name "Tabrez Iqbal" | |
# third cell: only run when github repo needs to be cloned to google drive | |
!git clone git@github.com:tabrez/fastai-book.git | |
# fourth cell: setup to be able to run git commands | |
%cd /content/gdrive/MyDrive/Colab Notebooks/fastai-book | |
!cp /root/.ssh/id_ed25519 . | |
# fifth cell: run git commands | |
!git status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment