美文网首页
将本地项目上传至Github仓库(1231)

将本地项目上传至Github仓库(1231)

作者: Qin0821 | 来源:发表于2019-03-05 17:41 被阅读0次
  1. 创建Github仓库;
  2. 打开终端,cd到需要上传的项目路径,输入下列命令;
  3. git init 初始化本地仓库;
  4. git add . 把项目所有文件添加到本地git仓库中;
  5. git commit -m "Initial commit"提交到本地仓库,-m 后面跟着的是提交的message;
  6. add origin 仓库地址 添加远程仓库地址,如果出现fatal: remote origin already exists.​说明你已经添加过远程仓库了,git remote rm origin 然后再重新添加远程仓库地址;
  7. git push -u origin master 把文件提交到远程仓库;如果出现error:failed to push some refs to ...说明和远程仓库冲突了,需要先git pull origin master再merge,接着重新git push origin master
  8. 因为本地和远程是两个不相干的分支,所以push的时候可能会出现这个错误git push origin master,在上一步的命令后面添加--allow-unrelated-histories即可,如果是git pull或者git merge报这个错误,也是这么解决。

相关文章

网友评论

      本文标题:将本地项目上传至Github仓库(1231)

      本文链接:https://www.haomeiwen.com/subject/tttndqtx.html