一,先在git上创建一个项目
注意选择一个前缀,默认用户名
二,在本地创建项目
创建后,是没有git更新,push按钮的,因为没有关联到git
用命令:git init,这时项目文件变成红色了
三,本地项目关联到git仓库
创建git仓库,把本地项目与git远程仓库关联,Create Git Repository,下图没截准。
如果用命令: git remote add origin url
四,push项目到远程仓库
add,commit, push
从git上copy创建项目地址,就可以成功提交了
命令操作完成流程
git init
git add.
git commit -m 备注
git push -u origin master
遇到问题
1.fatal: refusing to merge unrelated histories
fatal: refusing to merge unrelated histories解决_天骄山仔的博客-CSDN博客
2.git创建完成之后,项目为空,没有git地址
在readme提交点什么
3.
4.Git:clone项目到本地之后报错->fatal: branch ‘master‘ does not exist
No tracked branch configured for branch master or the branch doesn‘t exist.
问题:使用clone拉取项目代码之后进行pull操作时提示关联,但关联的时候提示没有master->fatal: branch ‘master’ does not exist。
解决步骤:
1.git pull origin master --allow-unrelated-histories
2.git branch --set-upstream-to=origin/master master
4.解决方式同上