首页 > 代码库 > Github提交代码的流程
Github提交代码的流程
1、生成密钥公钥文件
ssh #检查是否安装SSH
ssh -keygen -t rsa #指定RSA算法生成密钥,紧接着按连续3个enter键(不需要输入密码),就会生成id_rsa和id_rsa.pub文件,一个密钥,一个公钥
MeWifi:demo cjy$ ssh usage: ssh [-1246AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec] [-D [bind_address:]port] [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file] [-L [bind_address:]port:host:hostport] [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port] [-Q cipher | cipher-auth | mac | kex | key] [-R [bind_address:]port:host:hostport] [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]] [user@]hostname [command] MeWifi:demo cjy$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/Users/cjy/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /Users/cjy/.ssh/id_rsa. Your public key has been saved in /Users/cjy/.ssh/id_rsa.pub. The key fingerprint is: SHA256:RCZQ6JRaPSfyiN82HkRkFz9I0RC6Jpn01IduaCo89tk cjy@MeWifi.local The key‘s randomart image is: +---[RSA 2048]----+ | .B= X* | | *.=O.+. | | *.=o+= + | | o.o=o= . . | | .+o* S | | . .==. | | = .o o | | . + o. | | o E | +----[SHA256]-----+ MeWifi:demo cjy$ open ~/.ssh
2、GitHub上添加SSH key
第一步,在GitHub的settings中点击SSH and GPG keys:点击"New SSH key"按钮,将id_rsa.pub公钥文件里的内容复制粘贴进去即可,点击"ADD SSH key"按钮就OK了。
3、输入ssh -T git@github.com,查看是否添加成功了
MeWifi:demo cjy$ cd ~/.ssh MeWifi:.ssh cjy$ cat id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDWbDpGtr37mYsQr9S4GanayDbHQQ5509mT3Jytj+kZNtIKpKf0Jzql/OES18EieFweIkVdTj4IZlcEXzr7J5DgEHXMW0H2Nd2RYbSZQv5JjuRYibYvZVm9rqKwEhsERawv6+4ZVYRuC2/416bUM9bxtiyZ/jltsDYy90KC9sOYiNbyICB+YOBgWJoKGIe/I4go8b6Iqc6UInNv/QzMdEcKcahS0ZU1H9U8DEIJAx55d76xXOoaZJ5RtFnkm5YfArjhfpkgB9Ww1oZEw0ynAme7AMrDNvrkVQjxRRH7Nu1A49lTYZK5K2jUkLNIabJ0IWRYpjktXy6hq84GhfH72De9 xxx@xxx MeWifi:.ssh cjy$ ssh -T git@github.com Hi xxx! You‘ve successfully authenticated, but GitHub does not provide shell access.
4、提交代码
向GitHub提交代码有两种方法:
(1)Clone自己的项目
git clone git@github.com:username/test.git
这样就将test项目clone到本地了。这时的项目本身是一个远程仓库,不需要执行init操作,我们只要进行文件的新增,修改,然后commit一下就OK了,之后执行
git push origin mater,将本地代码推到远程仓库。
(2)关联本地已有项目
Github提交代码的流程
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。