Skip to content

Instantly share code, notes, and snippets.

@MohamedAliRashad
Created February 15, 2021 05:26
Show Gist options
  • Save MohamedAliRashad/d7e0336a867212091769bec63b5dd5d5 to your computer and use it in GitHub Desktop.
Save MohamedAliRashad/d7e0336a867212091769bec63b5dd5d5 to your computer and use it in GitHub Desktop.
Simple script to clone private git repos to colab
# Add repo_name & github username here
repo_name = "repo_name"
user = "owner_username"
# if it already exists, remove it
!rm -rf $repo_name
import os
from getpass import getpass
import urllib
password = getpass('Password: ')
password = urllib.parse.quote(password) # your password is converted into url format
cmd_string = 'git clone https://{0}:{1}@github.com/{0}/{2}.git'.format(user, password, repo_name)
os.system(cmd_string)
# removing the password from the variable
del cmd_string
del password
# Uncomment this if you want to add the repo to importing paths
# import sys
# sys.path.insert(1, "/content/{}".format(repo_name))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment