1. 登录github后,点右上角+号,选择New repository

2. 在页面中输入项目名、描述,设置为公开或私有项目,以及是否初始化的同时创建README

3. 因我本地已经有完整项目,前往本地项目目录,执行
git init
创建本地项目git仓库
4. 添加项目所有文件到本地仓库
git add ./*
git commit -m "Initial commit."
5. 将前面在github上新建的仓库pull下来,执行
git pull https://github.com/youraccount/yourprojectname.git
如果出现 fatal: refusing to merge unrelated histories

执行命令
git pull origin master --allow-unrelated-histories
强制合并
6. 添加远程版本库
git remote add origin https://github.com/youraccount/yourprojectname.git
7. 推送到github
git push -u origin master
网友评论