You can use SSH protocol to connect your private repo with colab
1) Generate SSH keys
2) upload it to colab
from google.colab import files
uploaded = files.upload()
3) Move the ssh kay pairs to /root and connect to git
- remove previously ssh files
! rm -rf /root/.ssh/*
! mkdir /root/.ssh
- uncompress your ssh files
! tar -xvzf ssh.tar.gz
- copy it to root
! cp ssh/* /root/.ssh && rm -rf ssh && rm -rf ssh.tar.gz ! chmod 700 /root/.ssh
- add your git server e.g gitlab as a ssh known host
! ssh-keyscan gitlab.com >> /root/.ssh/known_hosts
! chmod 644 /root/.ssh/known_hosts
- set your git account
! git config --global user.email "email"
! git config --global user.name "username"
- finally connect to your git server
! ssh git@gitlab.com
4) Authenticate your private repository
5) Use ! git@gitlab.com:{account}/{projectName}.git
note: to use push, you have to give write access for
the public ssh key that you authenticate git server with.