2016-10-11 22 views
3

私はGithubに新しいリポジトリを作成しました。 gitpythonライブラリを使用して、このリポジトリを取得できます。次に、新しいブランチを作成し、新しいファイルを追加し、コミットして新しいブランチにプッシュしようとします。以下ローカルブランチをリモートブランチにプッシュする - gitpython

ことを確認してくださいコード:最後のプッシュ方式まで細かい作業

import git 
import random 
import os 

repo_name = 'test' 
branch_name = 'feature4' 

remote_repo_addr_git = '[email protected]:DevOps/z_sandbox1.git' 

no = random.randint(0,1000) 
repo = git.Repo.clone_from(remote_repo_addr_git, repo_name) 
new_branch = repo.create_head(branch_name) 
repo.head.set_reference(new_branch) 
os.chdir(repo_name) 
open("parasol" + str(no), "w+").write(str(no)) # this is added 
print repo.active_branch 
repo.git.add(A=True) 
repo.git.commit(m='okej') 
repo.git.push(u='origin feature4') 

すべて。私はこのエラーを得た:

stderr: 'fatal: 'origin feature4' does not appear to be a git repository fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.'

は、私は、コマンドラインからこのメソッドを実行することができるよ、それがうまく働いています:

git puth -u origin feature4 

しかし、それはPythonで動作しません。私は何をすべきか教えてください。

答えて

0

これは動作するはずです:

repo.git.push("origin", "feature4") 
関連する問題