Skip to content

fatal: refusing to merge unrelated histories #125

@pdcmoreira

Description

@pdcmoreira

I'm getting the fatal: refusing to merge unrelated histories when I'm trying to merge branches, for some reason.

My steps:

- name: Use checkout v2
  uses: actions/checkout@v2
  with:
    ref: refs/heads/master
    token: ${{ secrets.GITHUB_CI_TOKEN }}
- name: Merge development into master
  run: |
    echo "# Config"
    git config --local user.email "[hidden]"
    git config --local user.name "CI"
    echo "# Fetch all"
    git fetch --all
    echo "# Checkout/pull development"
    git checkout development
    git pull
    echo "# Checkout/pull master"
    git checkout master
    git pull
    echo "# Merge"
    git merge development -X theirs
    echo "# Push"
    git push origin master

The error:
image

master and development branches can't have unrelated histories, because development was branched from master.

Running those commands locally works as expected.

Update:
Adding --allow-unrelated-histories to the merge command makes it work.
I don't understand how does git detect the branches as having different histories though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions