簡體   English   中英

我可以在本地編輯 main.workflow github-actions 文件嗎?

[英]Can I edit the main.workflow github-actions file locally?

如果我在本地更改我的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 Docs on Switching remote URLs from HTTPS to SSH

如果您使用的是 GitHub 桌面,則當前存在一個錯誤,在嘗試從 GitHub 操作推送提交時會導致此錯誤。 作為一種解決方法,您可以使用 Git API,直到發布此問題的修復程序。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM