【发布时间】:2021-05-27 05:01:52
【问题描述】:
所以我试图从我的一个私有存储库中将一个分支拉到 GitHub Actions 中,这样我就可以对其进行修改并将其推送回该存储库,但它不会让我这样做。虽然我可以克隆存储库,但由于我需要将修改后的文件推回存储库,这将不起作用。我运行命令的工作流在ubuntu-latest 上运行。另一件需要注意的是,当我在我的 Windows 计算机上运行这些相同的命令时,一切都运行正常,但由于某种原因,我不需要令牌或用户名来使链接工作。当我尝试从远程仓库拉取时,我收到以下错误。
remote: Repository not found.
fatal: repository 'https://github.com/[username]/[repo].git/' not found
Error: Process completed with exit code 1.
但是当我尝试克隆存储库时,该命令成功运行。我运行的命令如下。
我创建远程仓库
git remote add repo https://[username]:[token]@github.com/[username]/[repo].git
令牌具有repo 范围,因此它可以完全访问存储库。为了验证命令是否有效,我运行了
git remote -v
其中显示了我添加的新遥控器,因此我知道它有效。接下来我尝试从远程仓库中拉出master 分支
git pull repo master --allow-unrelated-histories
这是我得到错误的地方。克隆命令是
git clone https://[username]:[token]@github.com/[username]/[repo].git
与git pull 命令不同,此命令运行成功。
我查看了Git - remote: Repository not found 和Git Clone - Repository not found,但我尝试过的答案都没有帮助我。由于命令在我的本地计算机上运行,因此很可能不是命令,可能与 GitHub Actions 运行命令或令牌的方式有关。
导致问题发生的原因
- 创建一个私有仓库。
- 添加文件、提交、推送等
- 创建公共存储库。
- 添加工作流文件。
- 使用
repo范围创建个人访问令牌。 - 在公共回购中添加一个秘密并将其设置为
https://[username]:[token]@github.com/[username]/[private repo].git - 添加命令
git remote add repo ${{ secrets.[secret name] }}、git remote -v # To verify that the remote add worked、git pull repo [main/master branch]和ls - 提交并推送工作流文件,然后运行工作流。
- 打开会话日志查看错误
【问题讨论】:
-
git clone之后,git pull在本地存储库中是否正常工作? -
不想粗鲁.. 但我希望方括号中没有方括号是真实的
-
@MorisFinkel 是的。
-
“无关历史”错误确实表明这里发生的事情比您在问题中向我们展示的要多。如果您可以从头开始(即删除或重命名本地目录),然后使用导致错误的确切步骤顺序更新您的问题,那将有助于我们为您提供帮助。
-
@MorisFinkel 我试过
git remote update但它给出了与另一行相同的错误error: could not fetch repo。
标签: git github ubuntu-18.04 github-actions git-pull