使用git客户端第一次git clone github.com代码的方法

来源:互联网 发布:我国机电产品出口数据 编辑:程序博客网 时间:2024/06/16 16:48

使用git客户端第一次git clone github.com代码的方法

使用git-clone命令从github上同步github上的代码库时,如果使用SSH链接,而你的SSH key没有添加到github帐号设置中,系统会报下面的错误:

Permission denied (publickey).

fatal: Could not read from remote repository.

Please make sure you have the correct access rights

and the repository exists.

这时,需要在本地创建SSH key,然后将生成的SSH key文件内容添加到github帐号上去。创建ssh key的过程如下:
输入命令:ssh-keygen -t rsa -c "youremail@xx.com"

然后根据提示连按三次enter键,生成的SSH key文件就保存到C:\Users\Administrator.ssh文件夹下的id_rsa.pub文件中。
如图所示:
这里写图片描述

用文本工具打开id_rsa.pub文件,复制其内容。将其粘贴到github账号下的SSH key中。
登陆自己的github账号,选择“setting”选项,添加SSH key.如图所示:

这里写图片描述
这里写图片描述

然后就可以clone自己的github上的代码了。

git clone命令:git clone git@github.com:Jameszhjj/W3C.git

git add命令:git add -A

git commit命令:git commit -m " "

git push命令:git push (origin master)(括号内可选)

0 0