【问题标题】:Github Actions: [remote rejected] master -> master (shallow update not allowed), error: failed to push some refsGithub Actions: [remote denied] master -> master (shallow update not allowed), error: failed to push some refs
【发布时间】:2020-09-29 03:24:45
【问题描述】:

在我的 Github 工作流程中,我检查了两个存储库。随后,我将工作流存储库“repoA”的两个目录与​​存储库“repoB”合并。推送到 repoB 时,出现错误:

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.

我不明白为什么我的 repo 很浅以及如何修复它。 Github 工作流文件:

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

【问题讨论】:

    标签: github github-api github-actions


    【解决方案1】:

    默认情况下actions/checkout 只签出一个提交,使得签出很浅。如果您想要所有历史记录,您可以将fetch-depth 输入设置为0

    请参阅文档here

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

    【讨论】:

    • 完美,谢谢!我认为参数 --unshallow 已经在这样做了。
    猜你喜欢
    • 2019-11-30
    • 2016-08-08
    • 1970-01-01
    • 2013-11-21
    • 2018-01-28
    • 1970-01-01
    • 2016-09-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多