libgit2 / pygit2

Python bindings for libgit2
https://www.pygit2.org/
Other
1.58k stars 382 forks source link

How setup upstream for created new local branch? #1254

Closed Barto-Paja closed 6 months ago

Barto-Paja commented 7 months ago

Discussed in https://github.com/libgit2/pygit2/discussions/1253

Originally posted by **Barto-Paja** November 29, 2023 I've got this simple code. ``` try: new_branch = self.__repository.create_branch(branch_name, self.__repository.head.peel()) self.switch_branch(branch_name) callbacks = RemoteCallbacks(credentials=self.__credentials) ref_spec = "+refs/heads/{branch_name}:refs/remotes/origin/{branch_name}".format(branch_name=branch_name) self.__repository.remotes["origin"].push(specs=[str(ref_spec)], callbacks=callbacks) except pygit2.GitError as ge: raise Exception(ge) except Exception as e: raise Exception(e) ``` I need help, to set up upstream and push new branch created locally. How to do this? `self.__repository.remotes["origin"].push(specs=[str(ref_spec)], callbacks=callbacks)` doesn't throw any errors.