来自 IntelliJ IDEA 的 Git push --force

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22718000/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:54:31  来源:igfitidea点击:

Git push --force from IntelliJ IDEA

gitintellij-idea

提问by Jiri Peinlich

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 fore 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?

似乎从推送对话框中删除了强制选项。我目前正在使用 IntelliJ IDEA 13.1.1,但找不到任何方法如何使用前选项进行推送。我试图搜索文档,似乎在版本 10 中强制选项仍然存在。您是否知道如何从 IntelliJ IDEA 中用力推动?

采纳答案by VonC

As far as issue 85773is 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.

问题 85773而言,该选项不应出现在 GUI 中(对于 IDEA 11-12 或 13+)。
并且在主分支上时它会被禁用。

That is why issue 76252advocates 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.

这就是问题 76252提倡能够在 git 控制台中键入 git 命令的原因:这样,您仍然可以在不离开 IDE 的情况下执行正确的命令。



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

2014 年 11 月更新,适用于 IntelliJ 14(不会向后移植到 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.xmland thus is shared among the team.

要启用该功能,用户必须在设置 | 中选择“允许强制推送”。版本控制 | ”。

作为一些额外的保护,我们在那里添加了一个配置选项来指定“受保护”分支的列表,即不允许强制推送到的分支。
该值被保存.idea/vcs.xml并因此在团队之间共享。



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

2018 年 3 月更新:线程“ Intellij 2018.1 force push”提到:

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 settingsdetails:

Git 设置详细信息的帮助页面

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.

受保护的分支

如果您想禁用对某些分支强制推送更改的功能,请在此处列出它们(这是存储在 中的团队共享参数.idea/vcs.xml)。

您可以列出由分号分隔的多个分支,或者提供分支模式,因为输入被视为正则表达式列表。

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

因此,要具有强制推送的能力master,您需要从受保护分支列表中删除 master。

回答by Alim ?zdemir

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.

由于 IntelliJ IDEA 14 更新,可以为此启用复选框,您首先必须在设置->版本控制-> Git 中启用“允许强制推送”。

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

2018更新:为了让力推主分支,寻找在Git中设置“保护分支” - >然后删除值“主人”。