从标记(git)创建分支失败,maven发布插件:branch

从标记(git)创建分支失败,maven发布插件:branch,git,svn,maven-release-plugin,Git,Svn,Maven Release Plugin,我们正在尝试将一个简单的maven项目从svn迁移到git。我们使用的是maven release插件,工作流(当前)如下: trunk -> 2018.02.01-SNAPSHOT release:prepare release:perform ... tag -> 2018.02.01 trunk -> 2018.03.01-SNAPSHOT git checkout -b release/2018.02 2018.02.01 mvn build-helper:pa

我们正在尝试将一个简单的maven项目从svn迁移到git。我们使用的是maven release插件,工作流(当前)如下:

trunk -> 2018.02.01-SNAPSHOT

release:prepare release:perform ...

tag -> 2018.02.01
trunk -> 2018.03.01-SNAPSHOT
git checkout -b release/2018.02 2018.02.01

mvn build-helper:parse-version versions:set -DnewVersion=${parsedVersion.majorVersion}.${formattedVersion.minorVersion}.${formattedVersion.nextIncrementalVersion}-SNAPSHOT

mvn versions:commit

git commit -am "Bumped dev version for release branch."

git push
在trunk上工作时,请创建一个发布版本,并用如下内容标记它:

trunk -> 2018.02.01-SNAPSHOT

release:prepare release:perform ...

tag -> 2018.02.01
trunk -> 2018.03.01-SNAPSHOT
git checkout -b release/2018.02 2018.02.01

mvn build-helper:parse-version versions:set -DnewVersion=${parsedVersion.majorVersion}.${formattedVersion.minorVersion}.${formattedVersion.nextIncrementalVersion}-SNAPSHOT

mvn versions:commit

git commit -am "Bumped dev version for release branch."

git push
对于修补,我们从标记创建一个分支:

git checkout 2018.02.01
mvn -B release:branch -DbranchName=release/2018.02 -DupdateBranchVersions=true -DupdateWorkingCopyVersions=false
branch -> 2018.02.02-SNAPSHOT
这在SVN上运行良好,但在git上,我们得到以下错误:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building my-project 2018.02.01
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-release-plugin:2.5.3:branch (default-cli) @ my-project ---
[INFO] Verifying that there are no local modifications...
[INFO]   ignoring changes on: **/pom.xml.releaseBackup, **/pom.xml.next, **/pom.xml.tag, **/pom.xml.branch, **/release.properties, **/pom.xml.backup
[INFO] Executing: /bin/sh -c cd /home/hfm/git/my-project && git rev-parse --show-toplevel
[INFO] Working directory: /home/hfm/git/my-project
[INFO] Executing: /bin/sh -c cd /home/hfm/git/my-project && git status --porcelain .
[INFO] Working directory: /home/hfm/git/my-project
[INFO] Transforming 'my-project'...
[INFO] Checking in modified POMs...
[INFO] Executing: /bin/sh -c cd /home/hfm/git/my-project && git add -- pom.xml
[INFO] Working directory: /home/hfm/git/my-project
[INFO] Executing: /bin/sh -c cd /home/hfm/git/my-project && git rev-parse --show-toplevel
[INFO] Working directory: /home/hfm/git/my-project
[INFO] Executing: /bin/sh -c cd /home/hfm/git/my-project && git status --porcelain .
[INFO] Working directory: /home/hfm/git/my-project
[WARNING] Ignoring unrecognized line: ?? pom.xml.releaseBackup
[INFO] Executing: /bin/sh -c cd /home/hfm/git/my-project && git commit --verbose -F /tmp/maven-scm-112348369.commit pom.xml
[INFO] Working directory: /home/hfm/git/my-project
[INFO] Executing: /bin/sh -c cd /home/hfm/git/my-project && git symbolic-ref HEAD
[INFO] Working directory: /home/hfm/git/my-project
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.086 s
[INFO] Finished at: 2018-01-12T18:13:45+01:00
[INFO] Final Memory: 11M/184M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:branch (default-cli) on project my-project: An error is occurred in the checkin process: Exception while executing SCM command. Detecting the current branch failed: fatal: ref HEAD is not a symbolic ref -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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/MojoExecutionException
我理解错误消息
致命:ref HEAD不是符号ref
。这是因为我在分离模式下签出标记。但是如果我签入一个新分支,那么我将得到两个分支(一个是我手动创建的,另一个是由
发布:分支
目标创建的)


问题是,我们是否以错误的方式使用maven发布插件?或者它不是要以这种方式与git一起使用吗?

我们决定停止使用maven发布插件,而是在和的帮助下做同样的事情。步骤如下所示:

trunk -> 2018.02.01-SNAPSHOT

release:prepare release:perform ...

tag -> 2018.02.01
trunk -> 2018.03.01-SNAPSHOT
git checkout -b release/2018.02 2018.02.01

mvn build-helper:parse-version versions:set -DnewVersion=${parsedVersion.majorVersion}.${formattedVersion.minorVersion}.${formattedVersion.nextIncrementalVersion}-SNAPSHOT

mvn versions:commit

git commit -am "Bumped dev version for release branch."

git push