Git新手:git push origin master =“ssh_exchange_identifiction:远程主机关闭的连接。致命:远端意外挂断“ [英] New to Git: git push origin master = "ssh_exchange_identifiction: Connection closed by remote host. Fatal: The remote end hung up unexpectedly"
问题描述
我第一次尝试使用git,并试图按照github提供的说明进行操作。但是,我似乎没有完成最后一步。以下步骤由github提供:
全局设置:
下载并安装Git
git config --global user.nameYour Name
git config --global user.email
下一步:
mkdir SomeFolder
cd SomeFolder
git init
touch README
git add README
git commit -m'第一次提交'
git remote add origin git@github.com :username / SomeFolder.git
git push origin master
但是,当运行最终命令,git push origin master,我得到
ssh_exchange_identification:
由远程主机关闭的连接
fatal:远程终端意外挂起
为什么会这样?
GitHub高度安全,并遵循ssh-rsa
因此,我们需要为我们的连接设置为ssh公钥,并让github知道abo
以终端和用户身份(不是root用户,通常我们很多人习惯于在终端输入sudo su作为第一个commang,这次避开它)
type
ssh-keygen -t rsa -Cyourmailid@gmail.com
code>
在这里,
-t - >告诉哪个加密
-C - >尝试使用相同的邮件你已经给了ti github(为了便于记忆)
现在你将得到两个文件
id_rsa和id_rsa.pub in〜/ .ssh /
现在回到你的github帐户。
转到账户设置>>> SSH公共密钥
添加一个新的密钥
并将您复制的内容粘贴到字段密钥中并保存(给出您选择的标题)。现在github知道处理来自系统的请求。
现在尝试
$ ssh git@github.com
thuis必须返回嗨! UserName
如果显示任何错误,则忽略
但确保显示Hi! UserName
好的!现在我们要在本机上设置本地副本,并反映远程系统的变化。
创建一个目录(作为用户,而不是root)
mkdir MyProject
cd MyProject
git init
(在那里初始化一个空的git仓库,请参阅隐藏文件夹.git / there。)在MyProjects中创建文件后,当您想添加它到你的仓库在github,做
git add
现在运行状态并检查您将要提交的文件,
git status
git commit -m您对此提交的评论
(此更新本地存储库中的.git /文件夹)
现在我们告诉git有关要更新的远程存储库
git remote add origin git@github.com:username / ProjectName
(你记得我们从哪里得到 这个URL,它的你的克隆网址)
git push origin master
希望它能适合你。
I'm trying out git for the first time and am trying to follow instructions supplied by github. However, I seem to be failing on the last step. The following steps are provided by github:
Global setup:
Download and install Git
git config --global user.name "Your Name"
git config --global user.email
Next steps:
mkdir SomeFolder
cd SomeFolder
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin git@github.com:username/SomeFolder.git
git push origin master
However, when running the final command, git push origin master, I get
"ssh_exchange_identification: Connection closed by remote host. fatal: The remote end hung up unexpectedly"
Why might this be?
GitHub is highly secured and follow ssh-rsa So we need to setup as ssh public key for our connection, and let github know about it.
take terminal and as user ( not root, usually many of us have a habit of typing sudo su as the first commang at terminal, this time avoid it) type
ssh-keygen -t rsa -C "yourmailid@gmail.com"
Here, -t -> tells which encryption -C ->try to use the same mail id you have given ti github (for ease of memory)
now you will get two files id_rsa and id_rsa.pub in ~/.ssh/
now copy the whole content in file id_rsa.pub without altering the content of the file.
Now go back to you github account. go to account settings >>> SSH Public Keys Add a new Key and paste the content you copied into field "key" and save (give a title of your choice).
now github know to process the requests from your system.
now try
$ssh git@github.com
thuis must return Hi! UserName ignore if any error is shown, but make sure , it shows Hi! UserName
okay! now we are going to set the repositories local copy on ouor machine and reflect changes at the remote system
make a directory ( as user, not root )
mkdir MyProject
cd MyProject
git init
( initialise an empty git repository there, see for a hidden folder .git/ there.) after creating files in MyProjects, when you feel like adding it to your repository at github, do
git add
now run status and check the files you are going to commit next,
git status
git commit -m "Your comment about this commit"
( this updates .git/ folder in your local repository ) now we tell git about the remote repository to be updated
git remote add origin git@github.com:username/ProjectName
( you remember from where we got this URL, its Your Clone URL )
git push origin master
Hope it will work for you.
这篇关于Git新手:git push origin master =“ssh_exchange_identifiction:远程主机关闭的连接。致命:远端意外挂断“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!