无法将 Git 推送到 Github - 'origin' 似乎不是 git 存储库/权限被拒绝 [英] Unable to Git-push master to Github - 'origin' does not appear to be a git repository / permission denied

查看:31
本文介绍了无法将 Git 推送到 Github - 'origin' 似乎不是 git 存储库/权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题与我在理解中的问题有关变基,分支和合并,和问题

<块引用>

当你的远程列表中有一个 teamMate 时,你如何提交你的 github 帐户?

我发现其他人也遇到了同样的问题.问题似乎与/etc/xinet.d/有关.

问题:无法将我的本地分支推送到我在 Github 的主分支

我跑

git push origin master

我明白了

fatal: 'origin' 似乎不是 git 存储库致命:远端意外挂断

错误消息表明分支origin"不在我的本地 git 存储库中.这样,Git 将停止连接到 Github.

这很奇怪,因为我还没有删除分支 'origin'.

我的 git 树是

 dev* 掌握蒂吉特遥控器/数学/数学遥控器/数学/大师遥控器/起源/主遥控器/马西/主

如何将本地分支推送到 Github,而您本地的 Git 中有 teamMate 的分支?

<小时>

VonC 的回答解决了主要问题.我为 ssh 密钥设置了密码.

我跑

$git push github master

我明白

权限被拒绝(公钥).致命:远端意外挂断

看来我需要以某种方式为 Git 提供密码.

如何让 Github 要求您提供密码而不是依赖 ssh 密钥?

解决方案

有什么作用

$ git config --get-regexp '^(remote|branch).'

返回(在您的 git 存储库中执行)?

Origin 只是引用远程 Git 存储库的默认命名约定.

如果它不引用 GitHub(而是指向您的队友存储库的路径,该路径可能不再有效或可用),只需添加另一个来源,例如 博客条目

$ git remote add origin2 git@github.com:myLogin/myProject.git$ git push origin2 master

(我实际上会使用名称 'github' 而不是 'origin' 或 'origin2')


<块引用>

权限被拒绝(公钥).
致命:远端意外挂断

检查您的 gitHub 身份是否在本地 Git 存储库中正确声明,如GitHub 帮助指南.(user.name 和 github.name -- 和 github.token)

然后,stonean blog 建议(如Marcio Garcia):

$ cd ~/.ssh$ ssh-add id_rsa

Aral Balkan 添加:创建配置文件

<块引用>

解决方案是在 ~/.ssh/下创建一个配置文件,如 本页 OS X 部分的底部.

这是我添加的文件,按照页面上的说明,我的推送又开始工作了:

托管 github.com用户 git端口 22主机名 github.com身份文件 ~/.ssh/id_rsaTCPKeepAlive 是身份只有是

您也可以发布

的结果

ssh -v git@github.com

了解有关 GitHub ssh 连接拒绝您的原因的更多信息.

还要检查您是否正确输入了您的公钥(它需要以=="结尾).
不要粘贴您的私钥,而是粘贴您的公钥.公钥看起来像:

ssh-rsa AAAAB3<此处的大字符串>== tek...@gmail.com

(注意:您是否为 ssh 密钥使用了密码?没有密码会更容易)

还要检查推送时使用的 url (git@github.com/...,而不是 git://github.com/...)

检查您是否有 SSH 代理来使用和缓存您的密钥.

试试这个:

 $ ssh -i path/to/public/key git@github.com

如果有效,则意味着您的 ssh 客户端没有将您的密钥发送到 GitHub.

This question is related to my problem in understanding rebase, branch and merge, and to the problem

How can you commit to your github account as you have a teamMate in your remote list?

I found out that other people have had the same problem. The problem seems to be related to /etc/xinet.d/.

Problem: unable to push my local branch to my master branch at 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.

This is strange, since I have not removed the branch 'origin'.

My git tree is

  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?


VonC's answer solves the main problem. I put a passphares to my ssh keys.

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.

How can you make Github ask for your passphrase rather than relying on the ssh key?

解决方案

What does

$ git config --get-regexp '^(remote|branch).'

returns (executed within your git repository) ?

Origin is just a default naming convention for referring to a remote Git repository.

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

$ git remote add origin2 git@github.com:myLogin/myProject.git
$ git push origin2 master

(I would actually use the name 'github' rather than 'origin' or '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)

Then, stonean blog suggests (as does Marcio Garcia):

$ cd ~/.ssh
$ ssh-add id_rsa

Aral Balkan adds: create a config file

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:

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 git@github.com

to have more information as to why GitHub ssh connection rejects you.

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>== tek...@gmail.com 

(Note: did you use a passphrase for your ssh keys ? It would be easier without a passphrase)

Check also the url used when pushing (git@github.com/..., not git://github.com/...)

Check that you do have a SSH Agent to use and cache your key.

Try this:

 $ ssh -i path/to/public/key git@github.com

If that works, then it means your key is not being sent to GitHub by your ssh client.

这篇关于无法将 Git 推送到 Github - 'origin' 似乎不是 git 存储库/权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆