Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gitpython returns 'git push --porcelain origin' returned with exit code 128

I'm trying to push a new git repo upstream using gitpython module. Below are the steps that I'm doing and get an error 128.

# Initialize a local git repo
init_repo = Repo.init(gitlocalrepodir+"%s" %(gitinitrepo))

# Add a file to this new local git repo
init_repo.index.add([filename])

# Initial commit
init_repo.index.commit('Initial Commit - %s' %(timestr))

# Create remote
init_repo.create_remote('origin', giturl+gitinitrepo+'.git')

# Push upstream (Origin)
init_repo.remotes.origin.push()

While executing the push(), gitpython throws an exception:

'git push --porcelain origin' returned with exit code 128

Access to github is via SSH.

Do you see anything wrong that I'm doing?

like image 954
newruby Avatar asked Jul 24 '26 11:07

newruby


1 Answers

I tracked it down with a similar approach:

class ProgressPrinter(git.RemoteProgress):

    def line_dropped(self, line):
        print("line dropped : " + str(line))

Which you can then call in your code:

init_repo.remotes.origin.push(progress=ProgressPrinter())
like image 110
zwessels Avatar answered Jul 26 '26 02:07

zwessels



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!