git--SSH key生成步骤

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/M_WBCG/article/details/75208221

windows上使用git首先需要下载https://git-for-windows.github.io/

Git是分布式的代码管理工具,远程的代码管理是基于SSH的,所以要使用远程的Git则需要SSH的配置

GithubSSH配置步骤:

第一步:设置Gituser nameemail

git config --global user.name "......."

git config --global user.email "........"

第二步:生成SSH密钥:

1、查看是否已经有了SSH密钥:cd ~/.ssh

如果没有密钥不会有此文件夹,有则备份删除

2、生成密钥

ssh-keygen -t rsa -C "[email protected]"

按3个回车,密码为空

最后在C:\Users\用户名\.ssh下得到了两个文件:id_rsaid_rsa.pub

也可以输入:cat ~/.ssh/id_rsa.pub直接进行查询

3、在github上添加SSH密钥,这要添加的是“id_rsa.pub”里面的公钥

打开https://github.com/settings/keys里面进行添加设置

4、测试ssh [email protected]

PTY allocation request failed on channel 0

Hi DesperChen! You've successfully authenticated, but GitHub does not provide shell access.

Connection to github.com closed.

三、开始使用github
1.获取源码:

$ git clone ......git

2.这样你的机器上就有一个repo了。
3.git于svn所不同的是git是分布式的,没有服务器概念。所有的人的机器上都有一个repo,每次提交都是给自己机器的repo
仓库初始化:

git init

生成快照并存入项目索引:

git add

文件,还有git rm,git mv等等…
项目索引提交:

git commit

4.协作编程:
将本地repo于远程的origin的repo合并,
推送本地更新到远程:

git push origin master

更新远程更新到本地:

git pull origin master

补充:
添加远端repo:

$ git remote add upstream.....git

重命名远端repo:

$ ......git为“upstream”

猜你喜欢

转载自blog.csdn.net/M_WBCG/article/details/75208221