bar*_*iro 7 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'
Run Code Online (Sandbox Code Playgroud)
即使使用.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)
Run Code Online (Sandbox Code Playgroud)
注意是否有一个https://代替git(SSH)。
然后做
git remote set-url origin git@github.com:USERNAME/REPOSITORY.git
Run Code Online (Sandbox Code Playgroud)
然后验证更改
$ git remote -v
# Verify new remote URL
> origin git@github.com:USERNAME/REPOSITORY.git (fetch)
> origin git@github.com:USERNAME/REPOSITORY.git (push)
Run Code Online (Sandbox Code Playgroud)
进一步阅读:Github Docs on Switching remote URLs from HTTPS to SSH
| 归档时间: |
|
| 查看次数: |
1320 次 |
| 最近记录: |