PART 1.ssh操作:建立本地与github和gitee的ssh连接
1.生成本地密钥
ssh-keygen -t rsa -C "[email protected]"
mv id_rsa gitee_id_rsa
mv id_rsa.pub gitee_id_rsa.pub
ssh-keygen -t rsa -C "[email protected]"
mv id_rsa github_id_rsa
mv id_rsa.pub github_id_rsa.pub
2.将本地公钥文件内容拷贝到github和gitee上
gitee_id_rsa.pub
github_id_rsa.pub
3.在本地建立config文集,内容如下:
####gitee########
Host gitee.com
HostName gitee.com
User ZLWang
IdentityFile ~/.ssh/gitee_id_rsa
####github########
Host github.com
HostName github.com
User wzl
IdentityFile ~/.ssh/github_id_rsa
4.测试连接
ssh -T [email protected]
Hi wangzenglong! You've successfully authenticated, but GitHub does not provide shell access.
ssh -T [email protected]
Hi ZLWang! You've successfully authenticated, but GITEE.COM does not provide shell access.
至此,本地与githee和github的ssh连接已经 建立。
PART 2.git操作:创建本地代码仓库,并推送到github和gitee
1.创建本地代码仓库
git init
git config user.name "ZLWang"
git config user.email "[email protected]"
git remote add origin [email protected]:ZLWang/DataPlatform.git
2.推送到github和gitee
git pull
git push -u -f origin master