`

github公钥配置- 本地上传代码

 
阅读更多

初次使用的时候,需要先注册一个github账号:https://github.com/maso53

 

在本地上传代码的步骤

1.生成密钥对

 

ssh-keygen

 2.拷贝密钥对

 

 

maso@Mac~/.ssh$cd ~/.ssh/  ;  cat id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFlOgMf/q/4FDO3GSmehrulichs9U6ZsB6XSl5BIpiurCvHFnrkYu/7+v47mK4DHLfPKXZMcoCBYJPS8WY2R4oQLAQ/3y7IPDacjh0pfnLtsaEItfWz4tmm3z9SEwMJxILKctPvjP4+DaUH08ppIeuVd03Z5dwJ2S8UE5d2wWriqnhq53Lau0J2hNxusHZ6pjtYHrXjRVoUydelLAQjxvcL7CqFTt5Z2kEadcCmsurEkH0VEvnHJVoaRhH3e/CJPOXdBDpdgkhrokBenxFG6TqhcEITiq7hOk7FucF/uX9WRNtNv8YRNP9pncjD/WZa2obuaozqia065FmZOy47XWt maso@Mac.local

3.登录github账号,到账号设置的地方添加本地生成的公钥

 

 

4.验证是否添加成功

 

maso@Mac~/.ssh$ ssh -T git@github.com
Warning: Permanently added the RSA host key for IP address '192.30.252.129' to the list of known hosts.
Hi maso53! You've successfully authenticated, but GitHub does not provide shell access.

  5.上传本地代码 , 先进入本地的目录

 

touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:maso53/mybatisTest.git
git push -u origin master

Counting objects: 3, done.
Writing objects: 100% (3/3), 203 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:maso53/mybatisTest.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin

 

这一步可能报错

maso@localhost/data/git/crmWeb$git push -u origin master
To git@github.com:maso53/crmWeb.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:maso53/crmWeb.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

 解决方法

git pull origin master

 

6.git常用命令

git  add  <filename>
git commit -m "comment"
git push -u origin master

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics