【问题标题】:GitHub Actions: `git push` to CodeCommit fails after rebaseGitHub Actions:在 rebase 后,`git push` 到 CodeCommit 失败
【发布时间】:2021-08-18 18:33:44
【问题描述】:

我目前正在处理将我的存储库保存到 AWS CodeCommit 的 GitHub 操作。它看起来像这样:

name: CI

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    
    steps:
      - name: "checkout"
        uses: actions/checkout@v2
      
      - name: "add aws codecommit remote"
        run: ...

      - name: "push repository to aws codecommit"
        run: |
          git fetch --tags
          git fetch --all
          git push aws --force --all
          git push aws --tags

此操作效果很好,但您可以通过执行以下操作来破坏它:

  • 结帐功能/a
  • 提交并推送一些东西
  • 结帐功能/b(来自功能/a)
  • 提交并推送一些东西
  • 结帐大师
  • 提交并推送一些内容
  • 结帐功能/b
  • 变基为主人
  • 再次推送

现在我收到以下错误:

error: remote unpack failed: Unknown commit XXXX
To https://git-codecommit.my-region-1.amazonaws.com/v1/repos/***
 ! [remote rejected] feature/b -> feature/b (unpacker error)
error: failed to push some refs to 'https://git-codecommit.my-region-1.amazonaws.com/v1/repos/***'
Error: Process completed with exit code 1.

有趣的是,如果我在本地计算机上执行完全相同的步骤,它就会起作用。我已经检查了这些问题的许多可能的解决方案,但它们都暗示了强制推送或权限问题,事实并非如此。无论如何我都尝试了这些解决方案,但没有任何效果。

有人给我小费吗?

干杯,提前谢谢你!

【问题讨论】:

  • 在使用action/checkout时,如果你想获取所有历史记录,你需要添加fetch-depth:0变量:reference
  • 妈的,原来这么简单!非常感谢@GuiFalourd。如果您将此作为答案发布,我会将其标记为正确:)
  • 谢谢 :) 我最近经历了类似的事情。根据您要执行的操作,有时您甚至需要添加 PAT,因为默认的 GITHUB_TOKEN 没有所有权限。

标签: git github-actions aws-codecommit


【解决方案1】:

使用action/checkout 时,如果要获取所有历史记录,则需要添加fetch-depth:0 变量:reference

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

【讨论】:

    猜你喜欢
    • 2011-11-21
    • 2016-04-14
    • 2010-11-05
    • 1970-01-01
    • 2015-07-17
    • 1970-01-01
    • 2014-10-29
    • 2020-01-14
    • 1970-01-01
    相关资源
    最近更新 更多