简体   繁体   中英

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:

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.

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:

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 .

The Theory:

The error specified seems pretty much Git only related: (Even though the release plugin has quite a bad reputation about 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.

What would happen then is that, if the remote master branch has those same lines modified as well, you couldn't push it normally. 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.

So I would tend to put the error on the Git side. 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 ! If it is the case, nothing you can do I am afraid.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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