The solution to my question is the following

Use with AIg = Github(token)
user = g.get_user()
repo = user.create_repo(full_name)
Answer from ustroetz on Stack Overflow
🌐
GitHub
https://gist.github.com › jkeesh › 3774227
Python script to create a remote git repo that checks out the latest commit with a post-receive hook · GitHub
Python script to create a remote git repo that checks out the latest commit with a post-receive hook - create_repo.py
🌐
GitHub
https://gist.github.com › skopp › 4159016
Python script to create a remote git repo that checks out the latest commit with a post-receive hook · GitHub
November 28, 2012 - Python script to create a remote git repo that checks out the latest commit with a post-receive hook - create_repo.py
Discussions

How do I create a remote git repository on my github account with python or push a local git repo to my github account using python? - Stack Overflow
The goal is to be able to automate ... it to GitHub with a python script that I will then run from the command line. Also, this is the first time I'm posting on StackOverflow so I apologize if I did not follow any conventions. Again I would appreciate clear explanations since it has only been 3 days since I started with python. ... Save this answer. ... Show activity on this post. I would suggest creating a remote repository, and then ... More on stackoverflow.com
🌐 stackoverflow.com
python - How to create a new repository with PyGithub - Stack Overflow
How can I create a new repository with PyGithub on Github? In particular I like to know how to use the create_repo method? How do I generate a AuthenticatedUser? More on stackoverflow.com
🌐 stackoverflow.com
python - Bash script to create new GitHub repository from template - Stack Overflow
I'm writing a bash script that can initialize a new repository from a GitHub template that I've already created. I'd like the script to replicate the steps laid out in this GitHub help doc, but I can't figure out how to use GitHub templates from the command line. I'm using Ubuntu 18.04 on WSL2. I've defined a function project() (see below) that takes one input (the name of the new project) and is supposed to do the following: ... call a python ... More on stackoverflow.com
🌐 stackoverflow.com
How to properly configure a Python project as a github repository
Just another tip for github, if you want to be sure that your system uses the key that you generated for this purpose, you can add a setting to $HOME/.ssh/config file, and set Host User git Hostname github.com IdentityFile IdentitiesOnly yes Useful if you have multiple unrelated keys on your system and want to force ssh to pick a specific one. Then you can use something like this ssh -T to test if what you did works. is basically now a standin for git@github.com More on reddit.com
🌐 r/learnprogramming
2
1
September 20, 2023
🌐
Medium
https://lavanya-gowda.medium.com › automate-github-repository-creation-and-initialization-using-python-e611009bd219
Automate GitHub repository creation and initialization using Python | by Lavanya Gowda | Medium
March 13, 2021 - But you have to run the above command on every terminal restart, so just go to ~/.bashrc or ~/.zshrc file and set the above command after the last line or anywhere you want. Now by default it will work on every terminal sessions. Create a new python script file and install PyGithub and python-dotenv packages by running following commands in terminal: ... import sys import os from dotenv import load_dotenv from github import Githubload_dotenv()path = os.getenv('FOLDERPATH') access_token = os.getenv('GITHUB_ACCESSTOKEN')def create_project(): folder_name = str(sys.argv[1]) newpath = os.path.join(path,folder_name) if not os.path.exists(newpath): os.makedirs(newpath) user = Github(access_token).get_user() repo = user.create_repo(name=folder_name, private=True) print(f"Succesfully created repository {folder_name}")if __name__ == '__main__': create_project()
🌐
Readthedocs
https://gitpython.readthedocs.io › en › stable › tutorial.html
GitPython Tutorial — GitPython 3.2.1 documentation
All code presented here originated ... purposes. All you need is a developer installation of git-python. The first step is to create a git.Repo object to represent your repository....
🌐
Medium
https://dilaing.medium.com › create-git-repositories-using-python-e64504d12b6a
Create Git Repositories in Terminal | by Dilain Gunasekara | Medium
May 7, 2021 - Then from code line 27 and below, it clone the repository and make a readme file and do the initial commit and push it to Github. ... If the -p flag is present it will create a private repository. Now let’s make this script run from anywhere. ... This will give script permission to execute. ... Now open your bashrc or zshrc file of your shell. ... Then add the path to the bottom of the file like below. ... Now save the file and reopen the terminal. Now you can execute the script from anywhere and no need to add python3 to beginning of the command.
🌐
Python GUIs
https://pythonguis.com › tutorials › getting started with git and github in your python projects
Git and GitHub for Python Projects: A Beginner's Guide to Version Control
April 8, 2026 - That's what most developers use while working with Git repositories. In our example, we could have run git checkout -b hello to create the hello branch and check out to it with one command. Let's make some changes to our project and create another commit. Go ahead and run the following commands: ... $ echo "print('Welcome to PythonGUIs!')" >> main.py $ cat main.py print('Hello, World!') print('Welcome to PythonGUIs!') $ git add main.py $ git commit -m "Extend our 'Hello, World' program with a welcome message."
Find elsewhere
🌐
Plain English Westminster
https://benhoyt.com › writings › pygit
pygit: Just enough of a Git client to create a repo, commit, and push itself to GitHub
pygit implements just enough of a Git client (in 500 lines of Python) to create a repo, commit, and push itself to GitHub.
🌐
Readthedocs
https://gitpython.readthedocs.io › en › stable › quickstart.html
GitPython Quick Start Tutorial — GitPython 3.2.1 documentation
Welcome to the GitPython Quickstart Guide! Designed for developers seeking a practical and interactive learning experience, this concise resource offers step-by-step code snippets to swiftly initialize/clone repositories, perform essential Git operations, and explore GitPython’s capabilities.
🌐
LinuxConfig
https://linuxconfig.org › home › how to manage git repositories with python
Manage Git Repositories with Python: GitPython Guide
May 27, 2022 - On Debian, and Debian-based distribution, the package is called “python3-git” and can be installed via apt: ... GitPython is available also in the Archlinux “Community” repository.
🌐
GitHub
https://github.com › benhoyt › pygit
GitHub - benhoyt/pygit: Just enough git (written in Python) to create a repo and push to GitHub · GitHub
pygit is just enough git (implemented in Python) to create a repo and push to GitHub. It's about 500 lines of Python 3 code that can create a repository, add files to the git index, commit, and push to GitHub.
Starred by 333 users
Forked by 55 users
Languages: Python
🌐
OpenGenus
https://iq.opengenus.org › create-github-repository-python
Python script to create GitHub repository
December 20, 2022 - To create a new repository on GitHub with code and images using Python, you will need to use the GitHub REST API and the requests library.
🌐
Real Python
https://realpython.com › python-git-github-intro
Introduction to Git and GitHub for Python Developers – Real Python
April 4, 2018 - Once that is set up, you will need a repo to work in. Creating a repo is simple. Use the git init command in a directory: ... $ mkdir example $ cd example $ git init Initialized empty Git repository in /home/jima/tmp/example/.git/
🌐
GeeksforGeeks
https://geeksforgeeks.org › automating-some-git-commands-with-python
Automating some git commands with Python - GeeksforGeeks
April 28, 2025 - To start automating Git commands with Python, you will first need to install GitPython by running the following command: ... To create a local copy of the repository at the specified local_path directory, using the repository URL repo_url
🌐
PDX
https://web.pdx.edu › ~gjay › teaching › mth271_2020 › html › 03_Working_with_git.html
Git Repo class in python
We shall use the python module gitpython to work with git. (We already used this module in the first overview lecture. The documentation of gitpython contains a lot of information on how to use its facilities. The main facility is the class called Repo which it uses to represent git repositories.
🌐
The Hitchhiker's Guide to Python
https://docs.python-guide.org › shipping › publishing
Publishing Your Code — The Hitchhiker's Guide to Python
On the newly created repo page, click “Manage topics” and add the tags “python” and “python3” and/or “python2” as appropriate. Include a link to your new GitHub repo in your project’s README file so people who just have the project distribution know where to find it. If this is a brand new repo, clone it to your local machine and start working: $ git clone https://github.com/<username>/<projectname>
🌐
GeeksforGeeks
https://geeksforgeeks.org › python › automating-some-git-commands-with-python
Automating some git commands with Python - GeeksforGeeks
April 8, 2026 - Enables integration of Git workflows into scripts and applications · Improves consistency and reduces human errors in version control operations · To start automating Git commands with Python, you will first need to install GitPython by running the following command: ... To create a local copy of the repository at the specified local_path directory, using the repository URL repo_url
🌐
Reddit
https://reddit.com › r/learnprogramming › how to properly configure a python project as a github repository
r/learnprogramming on Reddit: How to properly configure a Python project as a github repository
September 20, 2023 -

Hello all, i write often in Medium for topics about Python and Linux! in this article i describe how someone can configure a Python project as a github repository properly

https://medium.com/python-in-plain-english/python-how-to-properly-configure-a-project-as-github-repository-ae207238a713

Since there would be people that do not have medium subscription i post my article here as well, but if anyone wants to support me please read the article on medium and click "clap" :)

Python: How to Properly Configure a Project as a GitHub Repository

Usually when we work on Python projects we create virtual environments per project, those files are not needed under version control so it doesn't make sense to include them to the repository files, also configuring the project to push changes to remote repositories might be something trivial to experienced developers but new developers might struggle to do the configuration. In this article i will show you how to perform a Python project properly as Github repository, lets start!

Part 1: Create SSH keys for Github

My favorite and most straight forward way for me to authenticate with Github is with the usage of SSH keys, the procedure is to create a pair of private and public keys from our host and then copy the public key to Github, Then the git tool will use the private key to authenticate vs Github and perform all the needed actions to the remote repository, lets create our keys first.
WARNING: if you already have a pair of keys named id_rsa and id_rsa.pub on your ~/.ssh directory will overwrite your existing keys, so use with care!

$ ssh-keygen

Press enter on any prompts that will appea

Part 2: Copy the public key to your Github account

Goto:

Account Settings → SSH and GPG keys → Click on the “New SSH key” Button

Paste your public key here and give a Title, then Click “Add SSH key”

You are done! Github is not accepting Authentication requests using the key you created.

Part 3: Create and clone the repository

Create a new repository on Github, then click on “Code” → “SSH” and copy the git@github.com:<user>/<repository> parameter

Now on your computer open a terminal and enter

git clone git@github.com:kpatronas/test01.git

This will clone the repository to your computer ready to configure it for you Python project!

Part 4: Configure the Python virtual environment

A virtual environment is a sandbox that has its own Python and Installed Python libraries, its a very good practice that allows you to have separate environments with different library versions, to create a virtual environment for this project type the following:

Enter the repository directory

cd test01

Then create the virtual environment

virtualenv venv && cd venv

And finally install needed libraries, in this example i did the following

activated the virtual environment for this project using the source ./bin/activate command

install the fastapi Python library just for example. moved out the venv directory and created a requirements.txt file if the libraries installed to this environment, this is needed so the next guy who will clone our project will be able to install all the needed libraries using the pip command

source ./bin/activate
pip3 install fastapi
cd ..
pip3 freeze > requirements.txt

Part 5: Configure git properly

Next step here is to exclude things that we dont want under version control, one of those things are the virtual environment, is something that everyone can create since the requirements.txt exists, inside yor repo directory enter

echo 'venv' > .gitignore

What we just did is to enter the virtual environment directory name to .gitignore file, this file instructs git what files or directories to exclude from tracking

Part 6: First commit

Lets do our first commit to the repository , using git add we instruct git that we want to include all files under version control using the “.”

git add .

Now we are going to perform our first commit

git commit -m "First Commit"

And finally time to perform our push to the remote repository

git push -u origin main

The push should be completed without problems!

We can verify this by visiting the webpage of our github repository, we can verify that the requirements.txt exist but the virtual environment no!