2017-01-30 45 views
-1

私はローカルのgitリポジトリを持っています。私はgitpythonライブラリを使用してローカルのリポジトリをコミットするためにPythonを使用しています。コミットをgithubにプッシュしたいgitpythonや他のライブラリを使ってどうすればいいですか? 私はオンラインで見ましたが、解決策はありませんでした。誰もがこれで私を助けることができます。予め おかげpythonを使ったgit push

+0

https://gitpython.readthedocs.io/en/stable/reference.html#git.remote.PushInfo – hjpotter92

答えて

1
from git import Repo,remote 

rw_dir = 'path/to/your/local/repo' 
repo = Repo(rw_dir) 

'''Enter code to commit the repository here. 
After commit run the following code to push the commit to remote repo. 
I am pushing to master branch here''' 

origin = repo.remote(name='origin') 
origin.push() 
+3

このコードスニペットは、([説明を含む]問題を解決できるが、HTTP ://meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers)は本当にあなたの投稿の質を向上させるのに役立ちます。将来読者の質問に答えていることを覚えておいてください。そうした人々はあなたのコード提案の理由を知らないかもしれません。 [レビューから](https://stackoverflow.com/review/low-quality-posts/15052961) – Ferrybig