2016-09-29 15 views
2

gitpythonモジュールを使用して上流に新しいgit repoをプッシュしようとしています。以下は)(私がやってるのステップであり、プッシュの実行中にエラー128gitpythonは 'git push --porcelain origin'を返します。終了コード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() 

を取得し、gitpythonは例外をスロー:githubのに

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

のアクセスは、SSH経由です。

私がやっていることが間違っていますか?

答えて

0

gitコマンドの出力をキャプチャする必要があります。

を考えると、この進捗クラス:あなたはこれを実行すると

progress = Progress() 

try: 
    for info in remote.push(progress=progress): 
     info_callback(info) 

    for line in progress.allDroppedLines(): 
     log.info(line) 

except GitCommandError: 
    for line in progress.allErrorLines(): 
     log.error(line) 

    raise 

あなたはまだ128エラーになりますが、あなたはまた、出力を持っています:

class Progress(git.RemoteProgress): 
    def __init__(self, progress_call_back): 
     self.progress_call_back = progress_call_back 
     super().__init__() 

     self.__all_dropped_lines = [] 

    def update(self, op_code, cur_count, max_count=None, message=''): 
     pass 

    def line_dropped(self, line): 
     if line.startswith('POST git-upload-pack'): 
      return 

     self.__all_dropped_lines.append(line) 

    def allErrorLines(self): 
     return self.error_lines() + self.__all_dropped_lines 

    def allDroppedLines(self): 
     return self.__all_dropped_lines 

あなたはこのようなコードを書くことができます問題を説明するためにgit git。

関連する問題