aleksandr-m / gitflow-maven-plugin

The Git-Flow Maven Plugin supports various Git workflows, including GitFlow and GitHub Flow. This plugin runs Git and Maven commands from the command line.

Home Page:https://aleksandr-m.github.io/gitflow-maven-plugin/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

refusing to merge unrelated histories

alapierre opened this issue · comments

Probably this is not plugin problem, but I not know how to solve this issue.

Locally when I perform release everything works fine. But when I try to make release as an Azure Pipeline like this:

  - task: Bash@3
    displayName: Release prepare
    inputs:
      targetType: 'inline'
      script: |
        mvn -B gitflow:release-start

  - task: Bash@3
    displayName: Release perform
    inputs:
      targetType: 'inline'
      script: |
        mvn -B -DargLine="-Pdocker" gitflow:release-finish

I got error in release-finish on merging release branch

[INFO] --- gitflow-maven-plugin:1.18.0:release-finish (default-cli) @ camunda-service ---
[INFO] Checking for uncommitted changes.
[INFO] Checking out 'release/0.28.0' branch.
[INFO] Checking for SNAPSHOT versions in dependencies.
[INFO] Fetching remote branch 'origin release/0.28.0'.
[INFO] Comparing local branch 'release/0.28.0' with remote 'origin/release/0.28.0'.
[INFO] Fetching remote branch 'origin develop'.
[INFO] Comparing local branch 'develop' with remote 'origin/develop'.
[INFO] Local branch 'master' doesn't exist. Trying to fetch and check it out from 'origin'.
[INFO] Fetching remote branch 'origin master'.
[INFO] Creating a new branch 'master' from 'origin/master' and checking it out.
[INFO] Fetching remote branch 'origin master'.
[INFO] Comparing local branch 'master' with remote 'origin/master'.
[INFO] Checking out 'release/0.28.0' branch.
[INFO] Cleaning and testing the project.
[INFO] Running Maven goals: deploy
[INFO] Checking out 'master' branch.
[INFO] Merging (--no-ff) 'release/0.28.0' branch.
[ERROR] Failed to execute goal com.amashchenko.maven.plugin:gitflow-maven-plugin:1.18.0:release-finish (default-cli) on project camunda-service: release-finish: fatal: refusing to merge unrelated histories -> [Help 1]
[ERROR]

I have a lot of project with git-flow-maven-plugin and in all others release works perfectly on Azure DevOps.

@alapierre Hello. Take a look at issue with similar error - #340. There the problem was related to git clone depth.

Great tip, thank you @aleksandr-m. I do not know the reason but on some repos Azure DevOps use --depth=1 but on some others it is not. To solve refusing to merge unrelated histories just add in Azure pipeline definition:

variables:
  - name: Agent.Source.Git.ShallowFetchDepth
    value: 0