Github Actions: [remote rejected] master -> master (shallow update not allowed), error: failed to push some refs

亡梦爱人 提交于 2020-06-17 08:04:10

问题


In my Github workflow, I am checking out two repositories. Subsequently I merge two directories of the workflow repo "repoA" with repo "repoB". When pushing to repoB, I get an error:

From ../repoA
 * [new branch]      master     -> workspace/master
Automatic merge went well; stopped before committing as requested
[master cbd72fe] Update
To https://github.com/username/repoB.git
 ! [remote rejected] master -> master (shallow update not allowed)
error: failed to push some refs to 'https://username@github.com/username/repoB.git'
##[error]Process completed with exit code 1.

I don't understand why my repo is shallow and how to fix it. The Github workflow file:

name: test
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout current repo
      uses: actions/checkout@v2
      with:
        path: repoA
    - name: Checkout other repo
      uses: actions/checkout@v2
      with:
        repository: username/repoB
        path: repoB
        token: ${{ secrets.ACCESS_TOKEN }}
    - name: Update repo
      run: | 
        cd repoB
        git remote add repoa ../repoA
        git fetch --unshallow repoa
        git config --global user.email "asd@asd.com"
        git config --global user.name "username"
        git merge -s ours --no-commit --allow-unrelated-histories repoa/master
        rm -rf webserver
        rm -rf etl
        git add .
        git read-tree --prefix=webserver -u repoa/master:serv
        git read-tree --prefix=etl -u repoa/master:misc_projects/etl
        git add .
        git commit -m "Update" -a
        git push -f https://username@github.com/username/repoB.git

回答1:


By default actions/checkout only checks out a single commit, making the checkout shallow. If you want all history you can set the fetch-depth input to 0.

See the documentation here.

- uses: actions/checkout@v2
  with:
    fetch-depth: 0


来源:https://stackoverflow.com/questions/62291270/github-actions-remote-rejected-master-master-shallow-update-not-allowed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!