I created a new repository in my Github. Using the gitpython library, I can get this repository. Then I create a new branch, add a new file, commit and try to click on the new branch.
Please check the code below:
import git
import random
import os
repo_name = 'test'
branch_name = 'feature4'
remote_repo_addr_git = 'git@repo: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))
print repo.active_branch
repo.git.add(A=True)
repo.git.commit(m='okej')
repo.git.push(u='origin feature4')
Everything works fine until the last push method. I got this error:
stderr: 'fatal:' origin feature4 'does not seem to be a repository gitfatal: Failed to read from the remote repository.
Please make sure that you have the correct permissions and the repository exists.
I can run this method from the command line and it works fine:
git puth -u origin feature4
But this does not work in python. Could you tell me what to do?