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.
Discussed in https://github.com/libgit2/pygit2/discussions/1253