git Maven 发布:准备提交标记失败

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

Maven release:prepare fails to commit tag

gitmaven-release-plugin

提问by Peter N. Steinmetz

Attempting to perform a release on a maven project, which has successfully released before.

尝试对之前已成功发布的 Maven 项目执行发布。

When I perform mvn release:prepareI am prompted for the release tags and the new snapshot tags and the project builds.

当我执行mvn release:prepare时,系统会提示我输入发布标签和新快照标签以及项目构建。

But when it attempts to push to the remote, I get

但是当它尝试推送到遥控器时,我得到

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.0:prepare (default-cli) on project NeuralAnalysis: Unable to tag SCM [ERROR] Provider message: [ERROR] The git-push command failed. [ERROR] Command output: [ERROR] To ssh://[email protected]/NeuralAnalysis.git [ERROR] ! [rejected] NeuralAnalysis-1.5.6 -> NeuralAnalysis-1.5.6 (non-fast-forward) [ERROR] error: failed to push some refs to 'ssh://[email protected]/NeuralAnalysis.git' [ERROR] To prevent you from losing history, non-fast-forward updates were rejected

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.0:prepare (default-cli) on project NeuralAnalysis: Unable to tag SCM [ERROR] Provider message: [ERROR] The git-push command failed. [ERROR] Command output: [ERROR] To ssh://[email protected]/NeuralAnalysis.git [ERROR] ! [rejected] NeuralAnalysis-1.5.6 -> NeuralAnalysis-1.5.6 (non-fast-forward) [ERROR] error: failed to push some refs to 'ssh://[email protected]/NeuralAnalysis.git' [ERROR] To prevent you from losing history, non-fast-forward updates were rejected

And indeed, attempting to perform git push ssh://[email protected]/NeuralAnalysis.git NeuralAnalysis-1.5.6manually, also exits with the same complaint.

事实上,尝试git push ssh://[email protected]/NeuralAnalysis.git NeuralAnalysis-1.5.6手动执行,也会以同样的抱怨退出。

Performing git pullsays 'Already up-to-date'. git branchshows I am on the 'master'. git push origingives 'Everything up-to-date'.

表演git pull说“已经是最新的”。git branch显示我在“主人”上。git push origin给出“一切都是最新的”。

Looking at the repository using Tower shows that 'master', 'origin/master' and 'NeuralAnalysis-1.5.6' are all the same and on the last commit. The working directory contains release.properties and pom.xml.releaseBackup files.

使用 Tower 查看存储库显示“master”、“origin/master”和“NeuralAnalysis-1.5.6”都是相同的,并且是最后一次提交。工作目录包含 release.properties 和 pom.xml.releaseBackup 文件。

It looks to me like everything is fine with the repository overall.

在我看来,整个存储库的一切都很好。

回答by Peter N. Steinmetz

Turns out it was a remote tag with the same name, as suggested by VonC in the comment. This was likely created by some previously aborted release.

事实证明,这是一个同名的远程标签,正如 VonC 在评论中所建议的那样。这可能是由一些先前中止的版本造成的。

Although I found the remote tag by manually inspecting the refs/tags directory on the remote repository, git ls-remote --tagswill show them as well and the git push --verbosewill also show more about the problem in general.

虽然我通过手动检查远程存储库上的 refs/tags 目录找到了远程标签,但git ls-remote --tags也会显示它们,并且git push --verbose还会显示更多关于一般问题的信息。

To fix this, first retrieve the remote tags with git fetch --tags.

要解决此问题,请首先使用 检索远程标签git fetch --tags

One way to perform the next step is then to simply bypass that release tag by updating the pom.xml to have a higher -SNAPSHOT version (including any references in the same project by other modules to that snapshot), check these in, and do mvn release:clean; mvn release:prepareover again.

执行下一步的一种方法是通过更新 pom.xml 以具有更高的 -SNAPSHOT 版本(包括同一项目中其他模块对该快照的任何引用)来简单地绕过该发布标记,检查这些,然后执行mvn release:clean; mvn release:prepare再次。