プロジェクトに GitPython を利用する予定です。このコードを使用してテストすると、エラーが発生します。
repo.index.add(['*'])
repo.index.commit(message="Initial Commit")
repo.remotes.origin.push()
エラーは次のとおりです。
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:
その最後の行の後にメッセージはありません。ただし、コマンド ラインから手動で実行するgit push --porcelain origin
と、次のエラーが表示されます。
fatal: could not read Username for 'https://github.com': No such file or directory
これは公正なエラーです。これは真新しいリポジトリであり、まだ完全に構成していません。ただし、このプロジェクト (およびプッシュ機能) を複数のマシンに展開する予定であるため、GitPython を介して自動的に実行できるようにしたいと考えています。
ユーザー名とパスワードを設定して (または SSH キーを使用して) リモート リポジトリにプッシュするにはどうすればよいですか?