Methods for using Git with Google Colab

前端 未结 12 798
臣服心动
臣服心动 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:49

    You can almost use this link: https://qiita.com/Rowing0914/items/51a770925653c7c528f9

    as a summary of the above link you should do this steps:

    1- connect your google colab runtime to your Google Drive using this commands:

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

    It would need a authentication process. Do whatever it needs.

    2- Set current directory the path you want to clone the Git project there:

    in my example:

    path_clone = "drive/My Drive/projects"
    !cd path_clone
    

    don't forget to use ! in the beginning of cd command.

    3- Clone the Git project:

    !git clone 
    

    now you would have the cloned Git project in projects folder in you Google Drive (which is also connected to your Google Colab runtime machine)

    4- Go to your Google Drive (using browser or etc) and then go to the "projects" folder and open the .ipynb file that you want to use in Google Colab.

    5- Now you have Google Colab runtime with the .ipynb that you wanted to use which is also connected to your Google Drive and all cloned git files are in the Colab runtime's storage.

    Note:

    1- Check that your Colab runtime is connected to Google Drive. If it's not connected, just repeat the step #1 above.

    2- Double check by using "pwd" and "cd" commands that the current directory is related to the cloned git project in google Drive (step #2 above).

提交回复
热议问题