Dulwich ~ push to a certain branch

I would like to do the following with dulwich in an existing git repo:

  • change a file
  • commit
  • push to a certain branch (not master)

I read the documentation and also this post on SO, but I don’t get it. Can someone explain how to chose a specific branch to push to?

  • Programmatically `git checkout .` with dulwich
  • How to pull from the remote using dulwich?
  • Dulwich: How to automatically stage modified files
  • git-dulwich:how to merge or rebase?
  • How to get a list of tags and create new tags with python and dulwich in git?
  • How to get last commit for specified file with python(dulwich)?
  • Thanks

  • Git: Finding the two nearest commits of two repositories?
  • Error when syncing with Github for Mac app
  • Set username and email for msysgit portable
  • git: Find the oldest commit of `mine` which does not exist in `theirs`
  • Merge parent branch into child branch
  • Git hooks, post-receive loop through commit
  • One Solution collect form web for “Dulwich ~ push to a certain branch”

    During the push phase, you can specify how you would like to update the refs in the remote repository.

    E.g. (untested)::

     from dulwich.client import get_transport_and_path
     from dulwich.repo import Repo
     repo = Repo(".")
     client, path = get_transport_and_path("git+ssh://git@github.com/jelmer/foo")
     def update_refs(refs):
         refs["refs/heads/somebranch"] = repo["refs/heads/somebranch"]
     client.send_pack(path, update_refs, repo.object_store.generate_pack_contents)
    
    Git Baby is a git and github fan, let's start git clone.