1.初始化
git init
2.将当前目录下所有文件纳入git版本控制,如果当前目录有多个文件,可以将.换成文件名指定文件
git add .
3.提交到本地仓库
git commit -m "注释语句"
4.登录自己的gitlab账号,创建好仓库,然后进入到如下页面,点击clone,然后弹出的框中,复制下http路径
5.然后先执行命令 git pull https://gitlab.com/xxxx/xxx.git master --allow-unrelated-histories,注意–后面表示允许不相干的两个仓库合并,因为我们之前两个仓库是完全独立的,所以直接是没办法pull下来,需要加上后面参数才行
git pull https://gitlab.com/xxxx/xxx.git master --allow-unrelated-histories
6.然后执行如下命令将本地仓库和远程仓库关联,再push上去,push的时候会提示输入账号名和密码,输入即可成功
git remote add origin https://gitlab.com/xxxx/xxx.git
git push -u origin master
注意:本地分支与远程分支名字要相同