如何与GitHub同步,将本地文件push到到远程仓库

  • Run

    git config --global user.email "you@example.com"
    git config --global user.name "Your Name"

    to set your account's default identity.
    Omit --global to set the identity only in this repository.

    fatal: unable to auto-detect email address (got 'Administrator@WIN-GIUQ47V41UM.(none)')

  • 创建SSH Key
  1. 在用户目录下,看看有没有.ssh文件夹,如果有,再看看这个文件夹里有没有id_rsa和id_rsa.pub这两个文件夹,
  2. 若也有,则登录GitHub账号,打开Account settings,在Key文本框粘贴id_rsa.pub文件的内容,然后保存。
  3. 若没有,则打开Git Bash,创建SSH Key:ssh-keygen -t rsa -C "youremail@example.com",并重复上一步骤。
  • 在GitHub官网里登录自己的账号并且新建一个远程仓库

  • 打开git cmd

  • 找到自己的工程文件夹

  • 通过git init新建自己的本地仓库

  • 通过git add . 把文件添加到暂存区,不要忘记后面的小数点

  • 通过git commit -m "create new",将文件提交到仓库,引号内为提交说明

  • 通过 git remote add origin 你的远程地址来关联到远程仓库
    如:git remote add origin git@github.com:huahuajiadexiaogongju/SpringBootStudy.git

  • 通过git push -u origin master将本地库的内容推送到远程

    1. 第一次用 
      git push -u origin master
    2. 关联后直接用即可
      git push origin master
  • 到GitHub上的远程仓库进行刷新即可看到我们上传的项目



作者:啦啦啦哈啦啦啦
链接:https://www.jianshu.com/p/3aca836b932e
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

原文地址:https://www.cnblogs.com/show58/p/12357667.html