Git发布本地项目至仓库命令行操作流程

1.初始化项目

  git init

2.创建名称为 gh-pages 新分支(若直接发布至master分支,忽略此步)

  git checkout --orphan gh-pages

3.把所有内容加入本地git库

  git add .

4.提交内容至本地git库,并添加注释 first post

  git commit -m "first post"

5.将本地内容标记为即将发布内容至远程git库(提前建立名称为 luoxiaolei.github.io 库)

  git remote add origin https://github.com/luoxiaolei/luoxiaolei.github.io.git

6.将内容发布至远程git库

  git push origin master 发布至master分支

  git push origin gh-pages 发布至gh-pages分支

注意事项:

  如果本地的文件与远程仓库的文件不一致,需要先拉去远程文件

  git pull origin master --allow-unrelated-histories

  --allow-unrelated-histories 表示allow merging unrelated histories

参考链接:

  http://blog.csdn.net/lindexi_gd/article/details/52554159

原文地址:https://www.cnblogs.com/luoxiaolei/p/8460236.html