Skip to content

Is there a way to force a git push? #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
g12mcgov opened this issue Aug 5, 2015 · 2 comments
Closed

Is there a way to force a git push? #334

g12mcgov opened this issue Aug 5, 2015 · 2 comments

Comments

@g12mcgov
Copy link

g12mcgov commented Aug 5, 2015

Hi guys,

I'm using GitPython to commit and push some changes in my Python application. However, sometimes my developers and I want to force push the commit (git push --force) instead of sometimes the app failing because it's behind the HEAD of the repository.

Is there an option you can pass into the git.push() method? I haven't seen it documented anywhere and I figured I might as well ask.

Thanks.

@g12mcgov g12mcgov changed the title Is there a way to force a git push command? Is there a way to force a git push? Aug 5, 2015
@g12mcgov
Copy link
Author

g12mcgov commented Aug 5, 2015

Never mind, I made a random guess after reading through the source code, and found you can force it via the following keyword argument.

repo.git.push(force=True)

And that will do it. This should be documented somewhere.

@g12mcgov g12mcgov closed this as completed Aug 5, 2015
@Byron
Copy link
Member

Byron commented Aug 5, 2015

Great to hear that intuition led to the solution !
Indeed, the arguments to the <repo>.git.* methods are not documented in the tutorial, and I couldn't easily find explicit documentation about it elsewhere either. Users would certainly benefit from an update, and maybe you will feel like contributing to the documentation at some point - PRs are always welcome.

In short, this is how python arguments are translated to the command-line:

  • m=True -> -m
  • m="foo" -> -mfoo
  • message="foo" -> --message "foo"
  • -somethingveryspecial -> -somethingveryspecial
    • With non-keyword-arguments, the order is kept as is

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

No branches or pull requests

2 participants