无法使用 netbeans 将 master 分支推送到 git 存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11274989/
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 07:10:01  来源:igfitidea点击:

Can't push master branch to git repository with netbeans

gitnetbeansbranchpush

提问by k3rn3lPan1c

I just installed netbeans and connect to my git repository throught ssh.

我刚刚安装了 netbeans 并通过 ssh 连接到我的 git 存储库。

Everything works fine except pushing master branch. Every time I commit some changes on master branch and trying to push branch I get this popup:

除了推送主分支外,一切正常。每次我在 master 分支上提交一些更改并尝试推送分支时,我都会收到此弹出窗口:

There were errors during the push.
Open output to see more details.

and the details are

细节是

==[IDE]== Jun 30, 2012 4:29:42 PM Pushing finished.
==[IDE]== Jun 30, 2012 4:32:38 PM Pushing
git push ssh://50.57.180.187:22/var/www/netbeans +refs/heads/master:refs/heads/master
Remote Repository Updates
Branch : master
Old Id : cc6de40b3236047b0212e318f9977a7b75395177
New Id : fe8f3af403524ba5731fdf1e0b8773c4ef223840
Result : REJECTED_OTHER_REASON

Local Repository Updates
Branch : origin/master
Old Id : cc6de40b3236047b0212e318f9977a7b75395177
New Id : fe8f3af403524ba5731fdf1e0b8773c4ef223840
Result : NOT_ATTEMPTED

==[IDE]== Jun 30, 2012 4:32:43 PM Pushing finished.

But with other branches everything works great. Am I doing something wrong?

但是对于其他分支,一切都很好。难道我做错了什么?

EDIT: Remote repo was not bare, more info here

编辑:远程仓库不是裸的,更多信息在这里

采纳答案by VonC

You must be trying to push a new commit to replace an existing commit already push ("history rewritten")

您必须尝试推送新提交以替换已推送的现有提交(“重写历史”)

You need to do a git push --force, or select a similar option (if supported) in the git push wizard dialog of NetBeans.
And that suppose that the "push --force" is authorized on the remote repo (which isn't always the case).
If other have already pulled from the remote repo, rewriting its history is generally not a good idea.

您需要git push --forceNetBeans的 git push 向导对话框中执行或选择类似的选项(如果支持)。
并且假设“ push --force”在远程存储库上获得授权(情况并非总是如此)。
如果其他人已经从远程仓库中拉取了,重写它的历史通常不是一个好主意。

回答by denis

Looks like the problem is that your git repository is not bare.

看起来问题在于您的 git 存储库不是空的。

To verify yo can try pushing via git on the command line, it will give more detailed explanation.

为了验证你可以尝试在命令行上通过 git push,它会给出更详细的解释。

The problem might be that master is currently checked out at remote repository. To be able to push master branch you can try checking out something else than master on remote repository.

问题可能是 master 当前已在远程存储库中签出。为了能够推送 master 分支,您可以尝试在远程存储库上检查 master 以外的其他东西。

回答by ndo

I had the same issue with push via netbeans (on mac), caused by another circumstance:

我在通过 netbeans(在 mac 上)推送时遇到了同样的问题,这是由另一种情况引起的:

I (accidentally) used german umlauts (ü,?,?) for the name of my branch when creating it locally. Working locally worked fine until i tried to push it to the remote repository.

在本地创建分支时,我(不小心)使用了德语变音符号 (ü,?,?) 作为我的分支的名称。在本地工作正常,直到我尝试将其推送到远程存储库。

My workaround: create another branch locally without umlaut in its name, merge the wrong named branch into it, push the new one to the remote repo.

我的解决方法:在本地创建另一个名称中没有变音符号的分支,将错误命名的分支合并到其中,将新分支推送到远程仓库。

hope this helps someone saving time while searching the solution.

希望这有助于某人在搜索解决方案时节省时间。