简体   繁体   English

git push 使用 Maven 发布插件失败

[英]git push fails using maven release plugin

running git version 1.7 and maven 3.0.3 and maven release plugin 2.4.2 and attempting to run the following command:运行 git 1.7 版和 maven 3.0.3 和 maven 发布插件 2.4.2 并尝试运行以下命令:

mvn clean install release:clean release:prepare release:perform

I receive the following error:我收到以下错误:

[INFO] Checking in modified POMs...
[INFO] Executing: /bin/sh -c cd /home/foo-proj && git add -- pom.xml
[INFO] Working directory: /home/foo-proj
[INFO] Executing: /bin/sh -c cd /home/foo-proj && git status
[INFO] Working directory: /home/foo-proj
[INFO] Executing: /bin/sh -c cd /home/foo-proj && git commit --verbose -F /tmp/maven-scm-1966810637.commit pom.xml
[INFO] Working directory: /home/foo-proj
[INFO] Executing: /bin/sh -c cd /home/foo-proj && git symbolic-ref HEAD
[INFO] Working directory: /home/foo-proj
[INFO] Executing: /bin/sh -c cd /home/foo-proj && git push ssh://git.acmeco.com/gitroot/foo-proj.git master:master
[INFO] Working directory: /home/foo-proj
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:03.408s
[INFO] Finished at: Sat Jun 14 21:30:48 UTC 2014
[INFO] Final Memory: 13M/57M
[INFO] ------------------------------------------------------------------------    
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.4.2:prepare    (default-cli) on project mikesbikes: Unable to commit files
[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] To ssh://git.acmeco.com/gitroot/foo-proj.git
[ERROR] ! [rejected]        master -> master (non-fast-forward)
[ERROR] error: failed to push some refs to 'ssh://git.acmeco.com/gitroot/foo-proj.git'
[ERROR] To prevent you from losing history, non-fast-forward updates were rejected
[ERROR] Merge the remote changes before pushing again.  See the 'Note about
[ERROR] fast-forwards' section of 'git push --help' for details.
[ERROR] -> [Help 1]

It's this line in particular that causes the problem:尤其是这一行导致了问题:

git push ssh://git.acmeco.com/gitroot/foo-proj.git master:master

If I do this by hand simply as git push I get no problem, so not sure what master:master actually means.如果我像 git push 一样手动执行此操作,我不会有问题,因此不确定 master:master 的实际含义。

I've searched exhaustively to look for similar issues online and only a few references to the same problem with no solution.我已经在网上进行了详尽的搜索以寻找类似的问题,并且只有少数参考文献提到了相同的问题而没有解决方案。 Any suggestions on what may be the issue would be greatly appreciated.任何关于可能是什么问题的建议将不胜感激。

edit: here's the output from the -e flag:编辑:这是-e标志的输出:

error: failed to push some refs to 'ssh://git.acmeco.com/gitroot/proj-foo.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again.  See the 'Note about
fast-forwards' section of 'git push --help' for details.

    at   org.apache.maven.plugins.release.PrepareReleaseMojo.prepareRelease(PrepareReleaseMojo.java:285)
    at   org.apache.maven.plugins.release.PrepareReleaseMojo.execute(PrepareReleaseMojo.java:232)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 19 more
Caused by: org.apache.maven.shared.release.scm.ReleaseScmCommandException: Unable to commit files
Provider message:
The git-push command failed.
Command output:
To ssh://git.acemco.com/gitroot/foo-proj.git
! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'ssh://git.acmeco.com/gitroot/foo-proj.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again.  See the 'Note about
fast-forwards' section of 'git push --help' for details.

    at org.apache.maven.shared.release.phase.AbstractScmCommitPhase.checkin(AbstractScmCommitPhase.java:165)
    at org.apache.maven.shared.release.phase.AbstractScmCommitPhase.performCheckins(AbstractScmCommitPhase.java:145)
    at org.apache.maven.shared.release.phase.ScmCommitPreparationPhase.runLogic(ScmCommitPreparationPhase.java:76)
    at org.apache.maven.shared.release.phase.AbstractScmCommitPhase.execute(AbstractScmCommitPhase.java:78)
    at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:234)
    at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:169)
    at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:146)
    at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:107)
    at org.apache.maven.plugins.release.PrepareReleaseMojo.prepareRelease(PrepareReleaseMojo.java:277)
    ... 22 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Are your master branch up to date with the remote one?您的主分支是否与远程分支保持同步?

Also, you might want to try to upgrade your Git to a version a bit younger (let's say 1.9.x ) and the latest maven release plugin which is currently 2.5.2 .此外,您可能想尝试将您的 Git 升级到一个更年轻的版本(比如1.9.x )和最新的 maven 发布插件,目前是2.5.2

The Theory:理论:

The error specified seems pretty much Git only related: (Even though the release plugin has quite a bad reputation about Git)指定的错误似乎只与 Git 相关:(即使发布插件在 Git 方面名声不佳)

[ERROR] To ssh://git.acmeco.com/gitroot/foo-proj.git
[ERROR] ! [rejected]        master -> master (non-fast-forward)
[ERROR] error: failed to push some refs to 'ssh://git.acmeco.com/gitroot/foo-proj.git'
[ERROR] To prevent you from losing history, non-fast-forward updates were rejected
[ERROR] Merge the remote changes before pushing again.  See the 'Note about
[ERROR] fast-forwards' section of 'git push --help' for details.
[ERROR] -> [Help 1]

Which generally means that there is potential conflicts.这通常意味着存在潜在的冲突。

What is happening during the release:prepare phase is that the Pom file is updated (with the new version) and a new commit is ... er... committed.release:prepare阶段发生的事情是 Pom 文件被更新(使用新版本)并且一个新的提交是......呃......提交。

What would happen then is that, if the remote master branch has those same lines modified as well, you couldn't push it normally.那么会发生的情况是,如果远程 master 分支也修改了相同的行,则无法正常推送它。 This would as well explain the fact that you can run the line manually afterward because there is a good chance that Maven would rollback the chance.这也可以解释您可以在之后手动运行该行的事实,因为 Maven 很有可能会回滚该机会。

So I would tend to put the error on the Git side.所以我倾向于把错误放在 Git 方面。 However, please note that I can't rule out the release:plugin because it is so flumsy sometimes that it might as well try to push something totally wrong !但是,请注意,我不能排除release:plugin可能性,因为它有时非常笨拙,以至于它可能会尝试推送完全错误的内容! If it is the case, nothing you can do I am afraid.如果是这样,恐怕你无能为力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM