如何上传项目至GitHub

1.下载

  https://gitforwindows.org/

2.打开Git Bash

   把git绑定到GitHub

3.打开GitHub登陆后

  1.   点击settings
  2.   点击SSH and GPG keys
  3.   点击 New SSH key
  4.   输入title

4.找key

  打开Git Bash 输入  

$ ssh-keygen -t rsa -C '你的注册邮箱'
  1.   回车提示输入密码,再回车两次
  2.   从提示路径里找到对应的.ssh文件
  3.   打开对应文件,里面有两个id_rsa,打开带pub的id_rsa(里面有注册邮箱),复制代码

5.把复制的key放到网页里面,点击确定

6.测试有没有绑定成功

  输入ssh -T git@github.com

  当弹出提示 You‘ve successfully authenticated 就绑定成功

7.设置用户信息(用于再提交的时候显示你的信息)

  查看 git config --list

  设置用户名:输入 git config --global user.name '用户名'

  设置用户邮箱: 输入 git config --global user.email '邮箱'

8.新建项目

  1.   点击网站右上角加号 +
  2.   点击 New repository
  3.   在 Repository name 输入项目名称
  4.   在 Description 输入项目描述
  5.   在Initialize this repository with a README 勾选

9.把项目放到本地

$ git clone git@github.com:XXXX/test1.git
// XXXX 是你的GitHub注册名称

10.把本地的代码上传至GitHub

  1.放到暂存区:

    上传单文件: git add 文件名 

    上传多文件: git  add .

  2.放到版本区

    git commit -m '注释'

  3.添加到GitHub

    git push origin master

11.团队协作开发

  新建分支

  将远程代码下拉到本地 git  pull

检查当前版本  

$ git checkout "新分支名"

查看当前状态

$ git status

然后在本地进行开发

  将开发的代码上传

// 添加文件到暂存区
$ git add .
// 上传至版本区 $ git commit -m '注释' // 上传至远程 $ git push

将分支branch与master合并

// 切换到master
$git checkout master

// 合并
$ git merge origin/index-swiper

  

  注意:

    日常开发,多人协作,当代码没有冲突,再合并到主支上

  

原文地址:https://www.cnblogs.com/shengnan-2017/p/9260032.html