Skip to content

Instantly share code, notes, and snippets.

@MathyV
Created March 22, 2018 19:30
Show Gist options
  • Save MathyV/80d2507f6843e391211f2ec5e0effa3c to your computer and use it in GitHub Desktop.
Save MathyV/80d2507f6843e391211f2ec5e0effa3c to your computer and use it in GitHub Desktop.
Force push with pygit2
# I had a need to force update and push the master branch
# Took me a while to find this so I thought I'd share
# Just add a + in front of the branch name and it will work
branch = "refs/heads/master"
repo.create_reference(branch, "refs/heads/develop", force=True)
repo.remotes['origin'].push(['+' + branch], callbacks=callbacks);
@homeday
Copy link

homeday commented Dec 9, 2022

ok, got it. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment