【发布时间】:2022-06-30 23:19:48
【问题描述】:
我有一个 github 操作,它创建一个工作树,将文件复制到其中,然后将其推送到一个分支(与操作所在的分支不同的分支)。
当使用ubuntu-latest 时,效果很好。
git worktree add -B ghpages html_build origin/ghpages
cp -a docs/. html_build/
cd html_build
git add .
git commit -m "ghpages"
git push
使用windows-2019 时,尝试推送到当前分支而不是工作树会失败。
git worktree add -B ghpages html_build origin/ghpages
robocopy .\docs\ .\html_build\ /MIR
cd html_build
git add .
git commit -m "ghpages"
git push
动作中的错误是:
remote: error: GH006: Protected branch update failed for refs/heads/main.
remote: error: At least 1 approving review is required by reviewers with write access.
To https://github.com/XXX/XX
! [remote rejected] main -> main (protected branch hook declined)
error: failed to push some refs to 'https://github.com/XXX/XX'
所以在 linux 上它正确地推送到 ghpages 分支,在 Windows 上它似乎尝试推送到我已保护的 main 分支。当我删除保护时,它实际上只是在推动它(而不是 ghpages)。
【问题讨论】:
-
根据docs.microsoft.com/en-us/windows-server/administration/…,
/mir是“等同于 /e 加 /purge”,所以这会破坏.git文件。这使得 in 中的所有文件成为主存储库的html_build目录的一部分,这反过来又解释了一切。你可能想要/e,而不是/mir。 -
@torek 哇。这令人沮丧。你能回答一下吗,我可以接受
-
我不“做”窗户,所以我没有测试过,但如果你有,我会把它变成答案。