1、git init
![](https://img.haomeiwen.com/i5796264/12d59bffaf95c4cb.png)
2、将文件提交到git仓库管理
git add + 需要添加的文件名 或者git add --all 将所有的文件全部添加
![](https://img.haomeiwen.com/i5796264/67db430d8b18a325.png)
3、将git管理的文件提交到本地仓库,git commit -m "提交备注"
![](https://img.haomeiwen.com/i5796264/58d64c11e03bce04.png)
4、在github上创建远程代码仓库
5、将本地的仓库关联到github上
git remote add origin https://github.com/5678/888.git
![](https://img.haomeiwen.com/i5796264/aa719098e4e81754.png)
6、拉取远程分支代码并合并
git pull --rebase origin master
![](https://img.haomeiwen.com/i5796264/143da28fbf818ab7.png)
7、将本地仓库代码提交到远程git仓库
git push -u origin master
![](https://img.haomeiwen.com/i5796264/e813dbb63b4011bd.png)
使用上面的命令提交时报错了,是因为本地没有README.md或该文件与远程仓库的README.md冲突,可以使用下面命令强制提交。
git push -u origin master -f
![](https://img.haomeiwen.com/i5796264/ed8a51a216da4d14.png)
网友评论