def set_branch(self, branch, force=False):
try:
if branch not in self.repo.branches and branch == 'master':
'''Make init commit'''
self.repo.index.add(["*"])
self.repo.index.commit("init")
remote = self.repo.create_remote('master', self.repo.remotes.origin.url)
remote.push(refspec='{}:{}'.format(self.repo.active_branch, 'master'))
if self.is_developer_mode():
return
if str(self.repo.active_branch) != branch:
self.repo.git.checkout(branch, force=force)
else:
self.pull()
except git.GitCommandError as exc:
ColorPrint.exit_after_print_messages(message=exc.stderr)
评论列表
文章目录