运行 git 版本 1.7 和 maven 3.0.3 以及 maven 发布插件 2.4.2 并尝试运行以下命令:
mvn clean install release:clean release:prepare release:perform
我收到以下错误:
[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]
尤其是这一行导致了问题:
git push ssh://git.acmeco.com/gitroot/foo-proj.git master:master
如果我简单地像 git push 一样手动执行此操作,我不会遇到任何问题,所以不确定 master:master 的实际含义。
我在网上进行了详尽的搜索以寻找类似的问题,并且只有少数提到相同问题但没有解决方案。任何有关可能存在问题的建议将不胜感激。
编辑:这是
-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
您的主分支是否与远程分支保持同步?
此外,您可能想尝试将 Git 升级到更年轻的版本(比如说 1.9.x)和最新的 Maven 版本插件,目前是 2.5.2。
理论:
指定的错误似乎几乎只与 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]
这通常意味着存在潜在的冲突。
在
release:prepare
阶段发生的事情是 Pom 文件被更新(使用新版本)并且新的提交......呃......提交。
然后会发生的情况是,如果远程主分支也修改了相同的行,则无法正常推送它。 这也解释了您可以随后手动运行该行的事实,因为 Maven 很有可能会回滚该机会。
所以我倾向于将错误放在 Git 端。 然而,请注意,我不能排除
release:plugin
,因为它有时是如此笨拙,以至于它可能会尝试推动一些完全错误的东西!如果是这样的话,恐怕你无能为力。