简体   繁体   English

无法将 git 本地 master 推送到远程仓库

[英]Unable to push git local master to remote repository

I'm just trying to push my local master to the remote repository on github, but this is not possible.我只是想将我的本地主服务器推送到 github 上的远程存储库,但这是不可能的。 I have already made a repository in my github directory - on the website, and the app that I'm working on is simple in that I've only been working on the local master - no branches or anything.我已经在我的 github 目录中创建了一个存储库 - 在网站上,我正在使用的应用程序很简单,因为我只在本地主机上工作 - 没有分支或任何东西。

When I try 'git push -u origin master' in the terminal, the reply is:当我在终端中尝试“git push -u origin master”时,回复是:

permission denied (publickey)
fatal: could not read from remote repository

When I try 'git push', the response is:当我尝试“git push”时,响应是:

fatal: the current branch master has no upstream branch. To push the 
current branch and set the remote as upstream, use 'git push --set-
upstream origin master'

But when I try 'git push --set-upstream origin master' I get:但是当我尝试“git push --set-upstream origin master”时,我得到:

Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I've been reading as much as I can online on this, but I can't get anywhere, so some advice would be much appreciated, thanks:-)我已经在网上尽可能多地阅读了这方面的内容,但我无处可去,所以非常感谢一些建议,谢谢:-)

You probably do not have permission to read or write from your created repository. 您可能没有权限从创建的存储库中进行读取或写入。 You will need to generate a new SSH key and add the public key to your Github account. 您将需要生成一个新的SSH密钥,并将公共密钥添加到您的Github帐户。 If you do not know how to do that it is described in detail on https://help.github.com/articles/connecting-to-github-with-ssh/ . 如果您不知道该怎么做, 请参阅https://help.github.com/articles/connecting-to-github-with-ssh/上的详细说明。

A bit late, but for any one else stumbling upon this, this worked for me.有点晚了,但对于任何其他绊倒这个的人来说,这对我有用。

  1. Open Powershell开通Powershell
  2. Type in "ssh-keygen" (generates your ssh key)输入“ssh-keygen”(生成您的 ssh 密钥)
  3. Type in "cat ~/.ssh/id_rsa.pub" (gets your key)输入“cat ~/.ssh/id_rsa.pub”(获取您的密钥)
  4. Should look something like this - "ssh-rsa WHOOOOOOLEBUNCHOFTEXT"应该看起来像这样 - “ssh-rsa WHOOOOOOLEBUNCHOFTEXT”
  5. Copy it and go to your repo SSH Keys settings (should be in the settings section somewhere. - Gitlab's settings is here https://gitlab.com/-/profile/keys )将它和 go 复制到你的 repo SSH 密钥设置(应该在设置部分的某个地方。- Gitlab 的设置在这里https://gitlab.com/-/profile/keys
  6. Create a new key and paste your ssh key in there.创建一个新密钥并将您的 ssh 密钥粘贴到其中。
  7. Ka-bAM - Should be able to push now Ka-bAM - 现在应该可以推送了

-- If you want to update branch --- -如果要更新分支-

git checkout master

git pull origin master

git checkout YOUR-BRANCH

git rebase master

-- if you want to commit your code --- -如果您要提交代码-

git add -A

git commit -m "any comment"

git push origin YOUR-BRANCH

git checkout master

git pull origin master

git checkout YOUR-BRANCH

git rebase master

and finally 最后

git push origin YOUR BRANCH

and after you will submit merge request 在您提交合并请求之后

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM