使用maven版本插件时git推送失败

1tu0hz3e  于 2022-11-22  发布在  Maven
关注(0)|答案(1)|浏览(303)

运行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
bvjxkvbb

bvjxkvbb1#

您的主分支是否与远程分支保持同步?
此外,你可能想尝试升级你的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文件被更新(用新版本),并且一个新的提交被......呃......提交。
如果远程master分支也修改了相同的行,您将无法正常推送它。这也可以解释为什么您可以在之后手动运行该行,因为Maven很有可能会回滚该操作。
所以我倾向于把错误放在Git的一边。但是,请注意,我不能排除release:plugin,因为它有时候是如此的混乱,以至于它可能会试图把一些完全错误的东西推出来!如果是这样的话,恐怕你无能为力。

相关问题