Skip to content

Instantly share code, notes, and snippets.

@encima
Last active September 14, 2020 19:50
Show Gist options
  • Save encima/6123067 to your computer and use it in GitHub Desktop.
Save encima/6123067 to your computer and use it in GitHub Desktop.
Using the PyGithub library to create a new repo and initiate it in the current director.|-|{"files":{"github_makerepo.py":{"env":"plain"}},"tag":"Python"}
from github import Github
import sys, os
if len(sys.argv) == 4:
g = Github(sys.argv[1], sys.argv[2])
g.get_user().create_repo(sys.argv[3])
print '' + sys.argv[3] + ' created!'
print os.getcwd()
os.system('git init')
os.system('git remote add origin https://github.com/encima/%s.git' % sys.argv[3])
else:
print 'Call this from the directory you want the git repo in!'
print 'Usage: python github_makerepo.py <username> <password> <repo_name>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment