Methods for using Git with Google Colab

前端 未结 12 802
臣服心动
臣服心动 2020-12-12 11:42

Are there any recommended methods to integrate git with colab?

For example, is it possible to work off code from google source repositories or the likes?

Nei

12条回答
  •  Happy的楠姐
    2020-12-12 12:13

    The very simple and easy way to clone your private github repo in Google colab is as below.

    1. Your password won't be exposed
    2. Though your password contains special character also it works
    3. Just run the below snippet in Colab cell and it will execute in an interactive way
    import os
    from getpass import getpass
    import urllib
    
    user = input('User name: ')
    password = getpass('Password: ')
    password = urllib.parse.quote(password) # your password is converted into url format
    repo_name = input('Repo name: ')
    
    cmd_string = 'git clone https://{0}:{1}@github.com/{0}/{2}.git'.format(user, password, repo_name)
    
    os.system(cmd_string)
    cmd_string, password = "", "" # removing the password from the variable
    

提交回复
热议问题