注册GitHub账号

GitHub官网:www.github.com

配置公私钥

  1. 生成SSH

    1
    ssh-keygen -t rsa -b 4096 -C "test@example.com"

    可以一路回车,也可以根据提示进行修改。

  2. 查看公私钥

    进入~/.ssh目录即可看到。其中后缀为.pub的为公钥,需要粘贴到GitHub或者其他远程服务器的ssh设置处。

  3. 添加公钥

    进入设置,点击SSH and GPG keys,然后就可以将生成的公钥复制到里边。

    image-20200816143155012

创建仓库

  1. 寻找创建仓库的入口

    image-20200816143321916

  2. 填写相关信息

    image-20200816143404592

  3. 点击创建

把本地仓库同步到GitHub

  1. 添加GitHub仓库地址

    1
    git remote add github git@github.com:xxxx/test1.git

    image-20200816144243454

    如果删除则将add换为remove

  2. 抓取远端

    1
    git fetch github master

    这条命令会抓取远端,但不会跟本地分支产生关联。

  3. 将本地master与远端master分支合并

    1
    git merge --allow-unrelated-histories github/master

    image-20200816145509694

    image-20200816145604631

  4. 将本地master分支推送到远端

    1
    git push github master

    image-20200816150049191