[码云](https://git.oschina.net ) 建议不要直接百度开源中国
一、生成并部署SSH key
1.如何生成ssh公钥
你可以按如下命令来生成sshkey:
ssh-keygen -t rsa -C "自己的邮箱xxx.com"
# Generating public/private rsa key pair.
# Enter file in which to save the key (/Users/bzwmac2/.ssh/id_rsa):
回车输入密码,尽量简单易记,再次确认密码
The key fingerprint is:
SHA256:nVrvW4rD9zXCC/lYpHhC0FLcU4O7xMniCm1UqAN+Yw xxx@xxx.com
The key's randomart image is:
+---[RSA 2048]----+
| ...o.. oo |
| .+ oo + . |
| .++..o + |
| E =o+ B |
| o S.* .. |
| . o.+.o= |
| o o+ =.+...|
| . =o*oo..|
| .++=. |
+----[SHA256]-----+
2.在Mac隐藏文件中找到.ssh

3.查看公钥
将id_rsa.pub直接拖入XCode打开复制
也可以输入命令:cat ~/.ssh/id_rsa.pub
然后粘贴到oschina添加公钥的地方
4.测试公钥
#测试 SSH 连接
ssh -T git@git.oschina.net
提示输入yes
Are you sure you want to continue connecting (yes/no)? yes
输入步骤一中设置的密码

返回
Welcome to Git@OSC, yourname!
配置SSH完成!
二、项目部署到oschina
1.新建项目

2.复制ssh地址,SourceTree克隆仓库

3.添加 .gitignore忽略文件
[github](https://github.com/github/gitignore ) 获取最新的gitignore,然后复制一份需要的.gitignore文件,粘贴到自己的项目中
添加.gitignore文件后,每次提交时不会将自己的项目设置信息提交到服务器,团队开发很重要

cd到文件目录,更改文件名
mv Swift.gitignore .gitignore

网友评论