Hi, currently I use the actions/checkout@v2 to implement the synchronization between two repos, the following is the Actions workflow file I used:
`
name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Git-version
run: git version
- name: Git-remote-add
run: git remote add adobe https://github.com/kooyear/aem-sync-to.git
- name: Git-fetch-all
run: git fetch --all
- name: Git-checkout-adobe
run: git checkout -b sync-demo-master adobe/master
- name: Git-merge
run: git merge master
- name: Git-push
run: git push --set-upstream adobe master`
when this workflow is running, I got an error from
git merge master
error info is
`
Run git merge master
fatal: refusing to merge unrelated histories
`
but when I run those commands in my local device, it works, the commands are
git clone https://github.com/kooyear/aem-sync-from aem-sync-from-m
cd aem-sync-from-m
git remote add adobe https://github.com/kooyear/aem-sync-to.git
git fetch --all
git checkout -b sync-demo-master adobe/master
git merge master
git push --set-upstream adobe master
Do you know what is the reason?
actions/checkout@v2 is optimized to fetch a single commit by default. If you want to fetch all history for all branches, add git fetch --prune --unshallow
@ericsciple Hi, thank you for your reply, I tried it, but still get the same error

@ericsciple , I also post my question in https://github.community/t5/GitHub-Actions/Sync-git-repo-with-Github-Actions/m-p/49037/highlight/false#M7356 , might be more clear to describe to explain the problem I met
Might need to git merge origin/master ?
@ericsciple still, I got the same error
Run git merge origin/master
fatal: refusing to merge unrelated histories
##[error]Process completed with exit code 128.
What I guess is the commands running in Github Actions environment are not as same as those running in my local device.
Can you help me to check if the outcome should be the same as commands below that I ran in my local device
git clone https://github.com/kooyear/aem-sync-from aem-sync-from-m
cd aem-sync-from-m
git remote add adobe https://github.com/kooyear/aem-sync-to.git
git fetch --all
git checkout -b sync-demo-master adobe/master
git merge master
git push --set-upstream adobe master
If you are only running on push for master, I would expect this to work:
on:
push:
branches: [ master ]
job:
asdf:
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.MY_TOKEN_WITH_PUSH_ACCESS_TO_THE_REMOTE }}
fetch-depth: 0
- run: |
git remote add adobe https://github.com/kooyear/aem-sync-to.git
git push --set-upstream adobe master
I dont think you want to run on the pull_request event trigger.
I had a similar problem and had to use git fetch --prune --unshallow per @ericsciple's suggestion along with a forced push:
-run
git fetch --prune --unshallow
git remote add remote_alias [ssh url_to_remote]
git push -f remote_alias master
Most helpful comment
I had a similar problem and had to use
git fetch --prune --unshallowper @ericsciple's suggestion along with a forced push:-rungit fetch --prune --unshallowgit remote add remote_alias [ssh url_to_remote]git push -f remote_alias master