天天看点

一文搞定github仓库上传维护

1 上传项目

  1. 新建github仓库
    一文搞定github仓库上传维护
  2. 项目文件夹处打开git

    鼠标右键git bash here即可。

  3. 初始化
$ git init
           
  1. 添加文件到仓库,.表示所有文件,也可以指定单个文件
  1. 上传说明,引号内容自定
  1. 关联远程仓库,远程仓库链接即上面创建的新仓库地址
$ git remote add origin https://github.com/xxx/xxx.git
           
  1. 上传到github
$ git push origin master:master
           

注:可能会报错error: failed to push some refs to ‘https://github.com/xxx’,请先运行下面命令,再重复第7步

$ git pull origin master --allow-unrelated-histories
           

2 更新项目

  1. 合并远程与本地仓库
$ git pull origin master --allow-unrelated-histories
           
  1. 添加文件到仓库,.表示所有文件,也可以指定单个文件
  1. 上传说明,引号内容自定
  1. 上传到github
$ git push origin master:master