Created
February 15, 2021 05:26
-
-
Save MohamedAliRashad/d7e0336a867212091769bec63b5dd5d5 to your computer and use it in GitHub Desktop.
Simple script to clone private git repos to colab
This file contains hidden or 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
# 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