Created
January 6, 2017 18:43
-
-
Save navinpai/d5c65558a678904e3afebeb0a0060391 to your computer and use it in GitHub Desktop.
Add Commit via PyGithub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import github | |
g = github.Github("username", "password") | |
repo = g.get_repo('username/reponame') | |
head_ref = repo.get_git_ref("heads/master") | |
latest_commit = gh_repo.get_git_commit(head_ref.object.sha) | |
base_tree = latest_commit.tree | |
new_tree = repo.create_git_tree([github.InputGitTreeElement(path="filename",mode='100644',type='blob',content="filecontent")],base_tree) | |
new_commit = repo.create_git_commit(message="commit message",parents=[latest_commit],tree=new_tree) | |
head_ref.edit(sha=new_commit.sha, force=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment