申请和使用github共享代码

1、申请github帐号

https://github.com/join?source=header-home

2、创建项目

 2.1

  

或者:

 

2.2 输入信息

 

 2.3创建成功,地址及基本命令提示

3、git客户端

 3.1 下载git客户端及安装

     https://git-scm.com/downloads

 3.2 生成 SSH 公钥

 1)  打开git命令窗口,或右键选“Git Bash Here”

 2) 创建 ~/.ssh 文件目录

      mkdir ~/.ssh

      cd ~/.ssh

  3)配置全局的name和email (Git上的帐号和邮箱)

      git config --global user.name "abc"

      git config --global user.email "123@qq.com"

  4)生成key

      ssh -keygen -t -rsa -C "123@qq.com"

成功后在你的电脑 会生成两个文件:

   

    3.3 配置git网站的SSH keys

       a.文本方式打开id_rsa.pub 全部复赋值

      

     b. 粘贴ssh key到git服务上

   

 ok,这里就配置完成了。

 4、建立本地仓库

   4.1 在你本地需要作为仓库的文件夹中 右键:“Git Bash Here”

     输入命令:

        git init
   git add README.md
   git commit -m "first commit"
   git remote add origin https://github.com/test.git
   git push -u origin master

以上代码是第一次提交的哦。

--第二次(或以后)提交到git
  git add .    --添加所有目录
  git commit -m "说明"  --提交
  git remote add origin https://github.com/test.git   --如果提示已经存在fatal: remote origin already exists.命令删除:$ git remote rm origin
  git push -u origin master --最后提交

提交成功后在github上即可查看到你的项目。

https://github.com/tongtongge

原文地址:https://www.cnblogs.com/tongyi/p/7212500.html