l
如果本地还没有创建项目
git clone git@gitlab.code100.cc:order-group/order-service.git
cd order-service
touch README.md
git add README.md
git commit -m "add README"
l
如果本地已经创建项目了
cd order-service
git init
git remote add origin https://gitlab.com/xxx/xx1.git
git add .
git commit -m "Initial commit"
git pull origin master --allow-unrelated-histories 如果遇到冲突执行 否则不执行
git push --set-upstream origin master
l
Master
分支 : 存放稳定的线上版本
一般我们用GitLab创建项目或者将本地项目提交到GitLab,会默认归属到Master分支
l
Develop
分支:平时日常开发测试使用
一般我们不会在Master分支上直接开发,会基于master分支创建一个Develop分支。
然后在develop分支上进行日常开发。
【记录一下遇到的问题】
•
git pull origin master --allow-unrelated-histories
•
error: Pulling is not possible because you have unmerged files.
•
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
•
hint: as appropriate to mark resolution and make a commit.
•
fatal: Exiting because of an unresolved conflict.
•
这个错误表明您有未解决的冲突,因此无法执行git pull操作。要解决这个问题,您需要手动解决冲突并完成合并。以下是一些步骤可以帮助您解决冲突:
•
•
查看冲突文件的状态:
•
git status
•
找到冲突的文件,并手动编辑文件以解决冲突。在文件中,冲突部分会用特殊标记标识,您需要决定如何解决冲突。
•
•
一旦您解决了冲突,将文件标记为已解决:
•
•
git add <冲突文件>
•
提交解决冲突的更改:
•
git commit -m "Resolve merge conflict"
•
最后,尝试再次执行git pull操作:
•
git pull origin master
•
git pull origin master
•
From https://gitlab.com/suwen1/hospital-parent
•
* branch master -> FETCH_HEAD
•
fatal: refusing to merge unrelated histories
•
这个错误通常发生在两个不相关的仓库历史尝试合并时。这可能是因为您的本地仓库和远程仓库的历史不一致导致的。
•
为了解决这个问题,您可以尝试在git pull命令中添加--allow-unrelated-histories选项,强制合并不相关的历史。请尝试以下命令:
•
git pull origin master --allow-unrelated-histories
•
这将允许您合并不相关的历史。完成合并后,您可以尝试再次推送您的更改到远程仓库:
•
git push origin master
如果提示上传邮箱则执行
•git config --global user.email “xxxxx@xx.com"
•
git
config
--global user.name
“xxxshuang"
•
git
config
--global
user.password
"password"