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:

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.
V2 sets the detch depth to 1 by default. You might need to either set fetch-depth: 0 or add the flag --unshallow to the fetch command.
Thanks, that makes sense!
@pdcmoreira thanks for confirmation. I'm updating the docs to make this more clear.
Most helpful comment
V2 sets the detch depth to 1 by default. You might need to either set
fetch-depth: 0or add the flag--unshallowto the fetch command.