Git - fatal: refusing to merge unrelated histories
将本地代码提交到远程gitHub步骤:在gitHub上创建仓库1. 现在本地初始化echo "# spring" >> README.mdgit initgit add README.md2. 本地提交git commit -m "first commit"3. 添加远程gitgit remote add origin https://github....
将本地代码提交到远程gitHub步骤:
在gitHub上创建仓库
1. 现在本地初始化
echo "# spring" >> README.md
git init
git add README.md
2. 本地提交
git commit -m "first commit"
3. 添加远程git
git remote add origin https://github.com/huyanmin/SpringRelate.git
4. 同步远程代码报错了
git pull origin master
原因: 上面新建的仓库中存在一个README.md的文件,git pull 时要将该文件pull到本地来,需要--allow-unrelated-histories
错误: fatal: refusing to merge unrelated histories
解决办法: git pull origin master --allow-unrelated-histories
运行结果如下:
5. 推送本地master去远程master
git push origin master:master
搞定啦!!!
其他相关git的命令:
设置远程仓库: git remote set-url origin https://github.com/huyanmin/SpringRelate.git
Error:
Can't Update
No tracked branch configured for branch 20190412 or the branch doesn't exist.
To make your branch track a remote branch call, for example,
git branch --set-upstream-to=origin/20190412 20190412 (show balloon)
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)