53

It seems that the force option was removed from the pushing dialog. I am currently using IntelliJ IDEA 13.1.1 and I cannot find any way how to push with force option. I tried to search the documentation and it seems that in version 10 the force option was still there. Do you maybe know how to push with force from IntelliJ IDEA?

Jiri Peinlich
  • 739
  • 1
  • 6
  • 10
  • Well, if they removed it, you will not be able to do it. Another reason why one shall keep the fingers off of Git front-ends that are not the console. See http://stackoverflow.com/a/21188318/520162 for more reasons. – eckes Mar 29 '14 at 05:39
  • Thanks, this works nicely for me because i worked with git already for a long time, but this does not work out of the box with other team members as they are currently only learning how to work with git. From experience IntelliJ provides us with nice UI where new team members learn quickly what to do and remember the commands. We just need the push force button for the case when we rebase feature branches. – Jiri Peinlich Mar 30 '14 at 06:46

3 Answers3

59

Since IntelliJ IDEA 14 update it's possible to enable a checkbox for exactly that, you first have to enable "Allow force push" in Settings->Version Control->Git.

2018 Update: To allow force push on master branch, look for "protected branches" in Git settings -> Then delete value "master".

Noam Manos
  • 15,216
  • 3
  • 86
  • 85
Alim Özdemir
  • 2,396
  • 1
  • 24
  • 35
40

As far as issue 85773 is concerned, that option shouldn't be in the GUI yet (for IDEA 11-12 or 13+).
And it would be disabled when on the master branch.

That is why issue 76252 advocates to be able to type git commands in the git console: that way, you still have a way to execute the right command, without leaving the IDE.


Update November 2014, for IntelliJ 14 (won't be backported to 13):

To enable the feature user have to select "Allow force push" in Settings | Version Control | Git".

As some additional protection we've added a configuration option there to specify the list of "protected" branches, i.e. branches which are not allowed to be force pushed to.
The value is saved in .idea/vcs.xml and thus is shared among the team.


Update March 2018: the thread "Intellij 2018.1 force push" mentions:

When a protected branch is selected as a target for a push in the Push dialog, Force push option is disabled.

If you push to some other branch, Force Push option is available.

The Help page on Git settings details:

Protected branches

If you want to disable the ability to force push changes for certain branches, list them here (this is a team-shared parameter that is stored in .idea/vcs.xml).

You can list several branches separated by a semicolon, or supply branch patterns as the input is treated as a list of regular expressions.

So to have the ability to force push against master, you need to delete master from the list of protected branches.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

I have been struggling to force push myself, and I found that when pressing the GitHub Push button, one can change from the Push command to Force Push:

enter image description here

Marine Galantin
  • 1,634
  • 1
  • 17
  • 28