Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save Mhmd-Hisham/2a7de2f7a3bb8b97617db76dea193e5b to your computer and use it in GitHub Desktop.

Select an option

Save Mhmd-Hisham/2a7de2f7a3bb8b97617db76dea193e5b to your computer and use it in GitHub Desktop.
Clone private GitHub repositories on Google Colab with a PSA (Personal Access Token)
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import getpass\n",
"\n",
"repo_name = input(\"Enter the name of the repository: \")\n",
"email = input(\"Enter your GitHub email: \")\n",
"username = input(\"Enter your GitHub username: \")\n",
"personal_access_token = getpass.getpass(prompt='Enter your personal access token: ')\n",
"\n",
"!git config --global user.email $email\n",
"!git config --global user.name $username\n",
"\n",
"!git clone \"https://{username}:{personal_access_token}@github.com/{username}/{repo_name}\"\n",
"\n",
"%cd \"{repo_name}\"\n",
"!git pull\n",
"\n",
"!ls"
]
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment