无法将 Git 推送到 Github - 'origin' 似乎不是 git 存储库/权限被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/922210/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to Git-push master to Github - 'origin' does not appear to be a git repository / permission denied
提问by Léo Léopold Hertz ??
This question is related to my problem in understanding rebase, branch and merge, and to the problem
这个问题与我在理解 rebase、branch 和 merge方面的问题以及问题有关
How can you commit to your github account as you have a teamMate in your remote list?
当您的远程列表中有 teamMate 时,您如何提交到您的 github 帐户?
I found out that other peoplehave had the same problem. The problem seems to be related to /etc/xinet.d/.
我发现其他人也有同样的问题。问题似乎与 /etc/xinet.d/ 有关。
Problem:unable to push my local branch to my master branch at Github
问题:无法将我的本地分支推送到 Github 的主分支
I run
我跑
git push origin master
I get
我得到
fatal: 'origin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
The error message suggests me that the branch 'origin' is not in my local git repository. This way, Git stops connecting to Github.
错误消息表明分支“origin”不在我的本地 git 存储库中。这样,Git 将停止连接到 Github。
This is strange, since I have not removed the branch 'origin'.
这很奇怪,因为我没有删除分支“原点”。
My git tree is
我的 git 树是
dev
* master
ticgit
remotes/Math/Math
remotes/Math/master
remotes/origin/master
remotes/Masi/master
How can you push your local branch to Github, while you have a teamMate's branch in your local Git?
当您的本地 Git 中有一个 teamMate 的分支时,您如何将您的本地分支推送到 Github?
VonC's answer solves the main problem. I put a passphares to my ssh keys.
VonC 的回答解决了主要问题。我给我的 ssh 密钥设置了密码。
I run
我跑
$git push github master
I get
我得到
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
It seems that I need to give the passphrase for Git somehow.
似乎我需要以某种方式为 Git 提供密码。
How can you make Github ask for your passphrase rather than relying on the ssh key?
如何让 Github 询问您的密码而不是依赖 ssh 密钥?
回答by VonC
What does
有什么作用
$ git config --get-regexp '^(remote|branch)\.'
returns (executed within your git repository) ?
返回(在您的 git 存储库中执行)?
Origin is just a default naming convention for referring to a remote Git repository.
Origin 只是引用远程 Git 存储库的默认命名约定。
If it does not refer to GitHub (but rather a path to your teammate repository, path which may no longer be valid or available), just add another origin, like in this Bloggitation entry
如果它不引用 GitHub(而是指向您的队友存储库的路径,该路径可能不再有效或可用),只需添加另一个来源,就像在这个博客条目中一样
$ git remote add origin2 [email protected]:myLogin/myProject.git
$ git push origin2 master
(I would actually use the name 'github' rather than 'origin' or 'origin2')
(我实际上会使用名称 'github' 而不是 'origin' 或 'origin2')
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
权限被拒绝(公钥)。
致命:远端意外挂断
Check if your gitHub identity is correctly declared in your local Git repository, as mentioned in the GitHub Help guide. (both user.name and github.name -- and github.token)
检查您的 gitHub 身份是否在本地 Git 存储库中正确声明,如GitHub 帮助指南 中所述。(user.name 和 github.name -- 和 github.token)
Then, stonean blogsuggests (as does Marcio Garcia):
然后,stonean 博客建议(和Marcio Garcia 一样):
$ cd ~/.ssh
$ ssh-add id_rsa
Aral Balkanadds: create a config file
Aral Balkan添加:创建配置文件
The solution was to create a config file under ~/.ssh/ as outlined at the bottom of the OS X section of this page.
Here's the file I added, as per the instructions on the page, and my pushes started working again:
解决方案是在 ~/.ssh/ 下创建一个配置文件,如本页 OS X 部分底部所述。
这是我添加的文件,按照页面上的说明,我的推送又开始工作了:
Host github.com
User git
Port 22
Hostname github.com
IdentityFile ~/.ssh/id_rsa
TCPKeepAlive yes
IdentitiesOnly yes
You can also post the result of
您也可以发布结果
ssh -v [email protected]
to have more information as to why GitHub ssh connection rejects you.
了解有关 GitHub ssh 连接拒绝您的原因的更多信息。
Check also you did enter correctly your public key (it needs to end with '==
').
Do not paste your private key, but your public one. A public key would look something like:
还要检查您是否正确输入了您的公钥(它需要以“ ==
”结尾)。
不要粘贴您的私钥,而是粘贴您的公钥。公钥看起来像:
ssh-rsa AAAAB3<big string here>== [email protected]
(Note: did you use a passphrase for your ssh keys ? It would be easier without a passphrase)
(注意:您是否为 ssh 密钥使用了密码?没有密码会更容易)
Check also the url used when pushing ([email protected]/...
, not git://github.com/...
)
还要检查推送 ( [email protected]/...
, not git://github.com/...
)时使用的 url
Check that you do have a SSH Agent to use and cache your key.
检查您是否有 SSH 代理来使用和缓存您的密钥。
Try this:
尝试这个:
$ ssh -i path/to/public/key [email protected]
If that works, then it means your key is not being sent to GitHub by your ssh client.
如果这有效,则意味着您的 ssh 客户端没有将您的密钥发送到 GitHub。
回答by Sarah Mei
This is a problem with your remote. When you do git push origin master
, origin
is the remote and master
is the branch you're pushing.
这是你的遥控器的问题。当您这样做时git push origin master
,origin
是远程并且master
是您正在推动的分支。
When you do this:
当你这样做时:
git remote
I bet the list does not include origin
. To re-add the origin remote:
我敢打赌该列表不包括origin
. 重新添加 origin 遥控器:
git remote add origin [email protected]:your_github_username/your_github_app.git
Or, if it exists but is formatted incorrectly:
或者,如果它存在但格式不正确:
git remote rm origin
git remote add origin [email protected]:your_github_username/your_github_app.git
回答by johnnygoodman
VonC's answer is best, but the part that worked for me was super simple and is kind of buried among a lot of other possible answers. If you are like me, you ran into this issue while running a "getting started with rails" tutorial and you had NOT setup your public/private SSH keys.
VonC 的答案是最好的,但对我有用的部分非常简单,并且被许多其他可能的答案所掩盖。如果您像我一样,在运行“Rails 入门”教程时遇到了这个问题,并且您没有设置您的公共/私人 SSH 密钥。
If so, try this:
如果是这样,试试这个:
$>cd ~/.ssh
$>ls
If the output of ls is
known_hosts
and nothing else, visit: http://help.github.com/mac-key-setup/and start following the instructions from the "Generating a key" section and down.
$>cd ~/.ssh
$>ls
如果 ls 的输出
known_hosts
没有别的,请访问:http: //help.github.com/mac-key-setup/并开始按照“生成密钥”部分的说明进行操作。
After running those instructions, my "git push origin master" command worked.
运行这些指令后,我的“git push origin master”命令起作用了。
回答by ken
I have the same problem and i think the firewall is blocking the git protocol. So in the end I have to resort to using https:// to fetch and push. However this will always prompt the user to enter the password...
我有同样的问题,我认为防火墙阻止了 git 协议。所以最后我不得不求助于使用 https:// 来获取和推送。但是,这将始终提示用户输入密码...
here is the example what working for me (just to share with those cant use git:// protocol :)
这是对我有用的示例(只是与那些不能使用 git:// 协议的人分享:)
git fetch https://[user-name]@github.com/[user-name]/[project].git
if the above works, you can remove the origin and replace with
如果上述方法有效,您可以删除原点并替换为
git remote rm origin
git remote add origin https://[user-name]@github.com/[user-name]/[project].git
回答by Julio Menendez
I got the same problem and I just added the content of ~/.ssh/id_rsa.pub to my account in GitHub. After that just try again git push origin master
, it should work.
我遇到了同样的问题,我只是将 ~/.ssh/id_rsa.pub 的内容添加到我在 GitHub 中的帐户中。之后再试一次git push origin master
,它应该可以工作。
回答by Aaron
I think that's another case of git error messages being misleading. Usually when I've seen that error it's due to ssh problems. Did you add your public ssh key to your github account?
我认为这是 git 错误消息具有误导性的另一种情况。通常,当我看到该错误时,它是由于 ssh 问题造成的。您是否将公共 ssh 密钥添加到您的 github 帐户?
Edit: Also, the xinet.d forum post is referring to running the git-daemon as a service so that people could pull from your system. It's not necessary to run git-daemon to push to github.
编辑:此外,xinet.d 论坛帖子指的是将 git-daemon 作为服务运行,以便人们可以从您的系统中提取。没有必要运行 git-daemon 来推送到 github。
回答by ATSiem
They key thing to remember is 'origin' is not the value you may need to be using... it worked for me when I replaced 'origin' with repo's name.
他们要记住的关键是“origin”不是您可能需要使用的值……当我用 repo 的名称替换“origin”时,它对我有用。
回答by Sravan
One possibility that the above answers don't address is that you may not have an ssh access from your shell. That is, you may be in a network (some college networks do this) where ssh service is blocked.In that case you will not only be able to get github services but also any other ssh services. You can test if this is the problem by trying to use any other ssh service.This was the case with me.
上述答案没有解决的一种可能性是您可能没有从 shell 访问 ssh 的权限。也就是说,您可能处于 ssh 服务被阻止的网络中(某些大学网络会这样做)。在这种情况下,您不仅可以获得 github 服务,还可以获得任何其他 ssh 服务。您可以通过尝试使用任何其他 ssh 服务来测试这是否是问题所在。我就是这种情况。
回答by sjpknight
I had this problem and tried various solutions to solve it including many of those listed above (config file, debug ssh etc). In the end, I resolved it by including the -uswitch in the git push, per the github instructions when creating a new repository onsite - Github new Repository
我遇到了这个问题并尝试了各种解决方案来解决它,包括上面列出的许多解决方案(配置文件、调试 ssh 等)。最后,我通过在 git push 中包含-u开关解决了这个问题,根据 github 说明在现场创建新存储库时 - Github new Repository