Search code examples
google-colaboratory

How can I reload a github repository in Google Colab


In first of my code in google Colab I clone a github repository:

 !git clone https://github.com/xyz/abc.git

Sometimes I need to modify the github repository and then run the code again. However, if I don't do Factory reset runtime, the changes won't be reflected after clone! It seems they are cached somewhere. I want to know if there are easier solutions instead of resetting runtime?


Solution

  • I'm assuming you are changing the github items somewhere else and simply want to take the latest into your Colab notebook. One option is to use git pull but you have to do that from the folder where your repository was downloaded. For your example, you would do this in one cell (note no !).

    cd abc
    

    Then in another cell, do this

    !git pull
    

    You would need to change directory back to where you started so do this.

    cd ..
    

    Another alternative is to delete the complete folder and do the clone again.

    !rm -r abc
    !git clone https://github.com/xyz/abc.git