Methods for using Git with Google Colab

前端 未结 12 811
臣服心动
臣服心动 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条回答
  •  鱼传尺愫
    2020-12-12 11:50

    Mount the drive using:

    from google.colab import drive
    drive.mount('/content/drive/')
    

    Then:

    %cd /content/drive/
    

    To clone the repo in your drive

    !git clone  
    

    Access other files from the repo(example: helper.py is another file in repo):

    import imp 
    helper = imp.new_module('helper')
    exec(open("drive/path/to/helper.py").read(), helper.__dict__)
    

提交回复
热议问题