git - GitHub Actions: `git push` to CodeCommit fails after rebase
问题描述
I am currently working on a GitHub Action that saves my repository to AWS CodeCommit. It looks like this:
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
This action works well, but you can break it by doing the following:
- Checkout feature/a
- Commit and push something
- Checkout feature/b (from feature/a)
- Commit and push something
- Checkout master
- Commit and push some things
- Checkout feature/b
- Rebase to master
- Push again
Now I get the following error:
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.
Funnily, it works if I perform the exact same steps on my local machine. I have checked many possible solutions to these problems, but they all suggest a force push or permission problems, which just isn't the case. I tried these solutions anyway, but nothing worked.
Does anyone have a tip for me?
Cheers and thank you in advance!
解决方案
When using the action/checkout
, you need to add the fetch-depth:0
variable if you wish to fetch all history: reference.
steps:
- name: "checkout"
uses: actions/checkout@v2
with:
fetch-depth: 0
推荐阅读
- jenkins - csv 文件的 Groovy JDBC eachrow 标头
- javascript - 在反应/材料 ui 中更改 TextField 颜色
- unit-testing - 在下面的 2 个存储库的 hadoop 中进行单元测试哪个更好?
- c++ - STL算法处理前N个符合条件的元素
- reactjs - 使用 React 中的 reducer 使用动态构造的对象更新状态
- php - 如何从 jquery 获取 mysql 数据库中的多个字段条目,从 php 获取 html 字段
- android - 如何在 xml 中为此 FAB 提供相等的空格?
- c++ - % 在变量旁边的代码中是什么意思?
- c# - Angular 6 不显示从 Asp Net Web API 2.2 检索到的数据
- python - 为什么 PyYAML/ruamel 在 Python 2 上结合转义代理?