I am planning on utilizing GitPython for my project. When I test it out, using this code I am receiving an error.
repo.index.add(['*'])
repo.index.commit(message="Initial Commit")
repo.remotes.origin.push()
The error is:
Traceback (most recent call last):
File "test.py", line 24, in <module>
repo.remotes.origin.push()
File "C:\Python27\lib\site-packages\git\remote.py", line 627, in push
return self._get_push_info(proc, progress or RemoteProgress())
File "C:\Python27\lib\site-packages\git\remote.py", line 564, in _get_push_info
finalize_process(proc)
File "C:\Python27\lib\site-packages\git\remote.py", line 64, in finalize_process
proc.wait()
File "C:\Python27\lib\site-packages\git\cmd.py", line 100, in wait
raise GitCommandError(self.args, status, self.proc.stderr.read())
git.exc.GitCommandError: 'git push --porcelain origin' returned exit status 128:
There is no message after that last line. However, if I manually run git push --porcelain origin
from the command line, I receive the error:
fatal: could not read Username for 'https://github.com': No such file or directory
This is a fair error. It's a brand new repository and I haven't fully configured yet. However, I plan on deploying this project (and the ability to push) across multiple machines so I'd prefer to be able to do automatically via GitPython.
How can I set the username and password (or utilize an SSH key) to push to the remote repository?