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工作。你能告訴我該怎麼辦?