【发布时间】:2021-12-20 19:41:14
【问题描述】:
我想更新我的存储库子模块,推送到它们各自的分支,然后将更改提交到我的主存储库并推送它。
这是我的 github 操作 yml:
---
name: Auto Update Submodules
# yamllint disable-line rule:truthy
on:
push:
# schedule:
# # Run every Wednesday at 4 AM.
# - cron: "0 4 * * WED"
jobs:
auto-update:
runs-on: ubuntu-latest
steps:
# Create private key to access private repos.
- uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- uses: actions/checkout@v2
with:
ref: '15.0'
submodules: true
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
persist-credentials: true
- name: Update submodules from origin
run: |
git submodule update --recursive --remote --merge --init --rebase
- name: Update from upstream and commit
run: |
git config --global user.name 'bot'
git config --global user.email 'bot@users.noreply.github.com'
cd src/odoo
git checkout 15.0
git remote add upstream git@github.com:odoo/odoo.git
git fetch upstream 15.0
git rebase upstream/15.0
git push
cd ../enterprise
git checkout 15.0
git remote add upstream git@github.com:odoo/enterprise.git
git fetch upstream 15.0
git rebase upstream/15.0
git push
cd ../..
git add .
git commit -m "[SUB] odoo/enterprise" || echo "No changes to commit"
git push origin 15.0
这是触发动作时得到的结果:
git submodule update --recursive --remote --merge --init --rebase
shell: /usr/bin/bash -e {0}
env:
SSH_AUTH_SOCK: /tmp/ssh-VxFJiDzXtsoG/agent.2130
SSH_AGENT_PID: 2131
Rebasing (1/1)
warning: Cannot merge binary files: stock_barcode/static/img/barcodes_demo.pdf (HEAD vs. 944ae3a4 ([I18N] Update translation terms from Transifex))
CONFLICT (add/add): Merge conflict in worksheet/i18n/sv.po
Auto-merging worksheet/i18n/sv.po
CONFLICT (add/add): Merge conflict in worksheet/i18n/de.po
Auto-merging worksheet/i18n/de.po
CONFLICT (add/add): Merge conflict in website_twitter_wall/i18n/zh_TW.po
Auto-merging website_twitter_wall/i18n/zh_TW.po
CONFLICT (add/add): Merge conflict in website_twitter_wall/i18n/vi.po
Auto-merging website_twitter_wall/i18n/vi.po
CONFLICT (add/add): Merge conflict in website_twitter_wall/i18n/th.po
Auto-merging website_twitter_wall/i18n/th.po
...
...
Error: Process completed with exit code 2.
如果我只从上游获取更改并使用它提交到主存储库,它会更新它。但随后进一步的工作流程中断,因为它找不到那些提交(直接来自上游存储库)。
我尝试从本地上游(从我的 PC)更新我的子模块,它工作正常。没有冲突,没有错误,(甚至不需要强制推送,因为我没有任何自定义更改):
git fetch upstream 15.0
git rebase upstream/15.0
git push
src/odoo 和 src/enterprise 是子模块的路径。
我对 github 操作的行为不同做错了什么?
会不会是因为它只获得了浅拷贝而导致事情中断?
【问题讨论】:
-
我没有仔细看这个,但
git submodule update --remote --merge --rebase肯定是错误的:--merge和--rebase是这里的独家选项。我认为最后一个覆盖,所以你得到--rebase行为,但我不想指望这一点。 -
(同时:是的,这可能是这里有问题的浅层克隆。鉴于你自己的答案,我现在已经略过,你可以通过完全删除
--merge --rebase来做到这一点,可能。)跨度> -
实际上,起初我试图在没有明确子模块更新的情况下进行更新,但我遇到了同样的问题。
-
是的,我认为你是对的,我应该使用 rebase 或 merge,但不能同时使用。
标签: git github-actions git-submodules