Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
jupyter-naas
GitHub Repository: jupyter-naas/awesome-notebooks
Path: blob/master/GitHub/GitHub_Create_repository_on_personal_account.ipynb
2973 views
Kernel: Python 3

GitHub.png

GitHub - Create repository on personal account

Give Feedback | Bug report

Tags: #github #productivity #code #operations #snippet

Last update: 2023-04-12 (Created: 2022-10-04)

Description: This notebook provides instructions on how to create a repository on a personal GitHub account.

Input

Importing library

import requests import json

Setup variables

# Enter your username here user_name = "jravenel" # Enter your github personal access token (Profile > Settings > Developpers settings > Personal access tokens) github_token = "**********" # Enter your repo name that you want to create repo_name = "test" # Enter Your repo description repo_description = "This is another repo"

Model

payload = {"name": repo_name, "description": repo_description, "auto_init": "true"} repo_request = requests.post( "https://api.github.com/" + "user/repos", auth=(user_name, github_token), data=json.dumps(payload), )

Output

if repo_request.status_code == 422: print("Github repo already exists try wih other name.") elif repo_request.status_code == 201: print("Github repo has created successfully.") elif repo_request.status_code == 401: print("You are unauthorized user for this action.")