26

I've searched the documentation and online also, but I can seem to find a way to do Git force push aka git push --force with IntelliJ, it is easy to do with the command line but how can you do it within the IDE itself?

2
  • Have a look on jetbrains.com/help/idea/commit-and-push-changes.html#push , bullet point 5. Since you don't say which version of IntelliJ you have, I'm going to assume that page from the manual applies. Commented Mar 14, 2020 at 16:00
  • That dropdown item can't be clicked Commented Mar 14, 2020 at 17:11

1 Answer 1

56

From the Push window (Ctrl/cmd-shift-K), the Push button has a down arrow to reveal a dropdown option ‘Force Push’. This will perform at first a --force-with-lease, which if fails, will prompt a --force push.

If your branch is trying to push to master, ‘Force Push’ is grey. To enable force push to master, remove it from the list of protected branches in Preferences → Git:

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! I appreciate the effort from JetBrains, but I really needed this out of the box :D
Interesting, but IntellIj should stop warn about "overwriting" commits. This is misleading. It should warn when it is appropriate, i.e. when force-with-lease failed, in my opinion.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.