git - 我可以在本地编辑 main.workflow github-actions 文件吗?

标签 git github github-actions

如果我在本地更改我的 main.workflow 文件,而不是在 master 分支中,提交并推送更改,我会从 push< 收到此错误命令:

> git diff
diff --git a/.github/main.workflow b/.github/main.workflow
index 135d8ea..0a13a28 100644
--- a/.github/main.workflow
+++ b/.github/main.workflow
@@ -6,7 +6,7 @@ workflow "Build and Test in PR" {
   ]
 }

-action ".NET Core CLI" {
+action ".NET Core CLI"  {
   uses = "./.github/net-core/"
   args = "test"
 }

> git push
! [remote rejected] my-branch -> my-branch (refusing to allow an integration to create or update .github/main.workflow)
error: failed to push some refs to 'https://github.com/my-user-name/my-repo.git'

最佳答案

即使使用 .yml 工作流程文件,仍然遇到此问题。事实证明,对我来说,这是因为我使用了 HTTPS 远程而不是 SSH。

为了在 Github API 中解决此问题,我只是使用 SSH 远程而不是 HTTPS。

您可以通过以下方式查看您使用的是 HTTPS 还是 SSH

$ git remote -v
> origin  https://github.com/USERNAME/REPOSITORY.git (fetch)
> origin  https://github.com/USERNAME/REPOSITORY.git (push)

注意是否有 https:// 而不是 git (SSH)。

然后做

git remote set-url origin git@github.com:USERNAME/REPOSITORY.git

然后验证更改

$ git remote -v
# Verify new remote URL
> origin  git@github.com:USERNAME/REPOSITORY.git (fetch)
> origin  git@github.com:USERNAME/REPOSITORY.git (push)

进一步阅读:Github 文档 Switching remote URLs from HTTPS to SSH

关于git - 我可以在本地编辑 main.workflow github-actions 文件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56600686/

相关文章:

git - 如何获取github工作流程的短sha?

git - 如何防止在 mac 上编辑导致整个文件显示为删除和添加的行?

html - 在 github 配置文件 README 中显示图像?

Github 操作 : failed with "lost connection"

visual-studio - 即使操作成功,PowerShell 也会在控制台中将一些 git 命令结果显示为错误

git - 如何简化 git log 以仅显示某些提交及其 merge 基础?

github - 如何将 Google Analytics 跟踪 ID 添加到 GitHub Pages

Github:检测 pull 请求及其大小

docker - 使用 GitHub Actions 设置 Docker 登录凭据助手

用于复制和重命名文件的 GitHub 操作