将本地项目推送到github

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

在前面将本地项目推送到码云上后(https://blog.csdn.net/wzyaiwl/article/details/86484122),我又想推送到github上,又该怎么做呢?下面来讲解下:

  • 生成公私钥
  1. 输入指令ssh-keygen生成密钥
  2. 进入用户home目录下.ssh 目录,id_rsa.pub 里面的内容就是生成的公钥Key,复制它。
  • 配置github
  1. 进入github的Settings,点击SSH and GPG keys,在右边写上自定义的title、粘贴上复制好的公钥。
  2. 新建一个空项目,只填写仓库名称和描述即可。
  3. 复制新建好仓库的ssh连接地址
  4. 检验本地是否可以连接github,输入指令:ssh -T [email protected],出现结果有You've successfully authenticated代表连接成功。


  • 本地推送上去
  1. 初始化本地仓库:git init  
  2. 将项目所有文件添加到仓库中: git add . 、git commit -m "xxx" 
  3. 添加远程连接:git remote add <shortname> <ssh_address>
  4. 查看本地仓库的远程连接:git remote -v
  5. 推送上去:git push <shortname> master
  • 本地推送上去(在本地仓库初始化完成的情况下)

只需要做上述的3~5步。

 

猜你喜欢

转载自blog.csdn.net/wzyaiwl/article/details/89499802