记录一次Git问题及其解决方案

简介:

错误信息:fatal: refusing to merge unrelated histories

错误产生背景:我将原先测试的项目本地删除后提交,然后将新的项目按照git的提交步骤进行提交,在最后一步,也就是提交到远程仓库的时候出现如下错误:
To https://code.aliyun.com/test/test-saas.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://code.aliyun.com/test/test-saas.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

这段信息简单的说就是说远程与本地不同步,推送失败。

解决办法自然是通过git pull命令 进行同步
但是当git pull时就出现上述的错误信息,也就是这段话:fatal: refusing to merge unrelated histories
翻译过来的意思是: 拒绝合并不相关的历史

因为之前的那个项目与这个完全没有任何关系,仅仅就是个测试。
那么如何解决呢?
通过git命令行强制合并即可,在git pull origin master 加上--allow-unrelated-histories
命令如下:
git pull origin master --allow-unrelated-histories

最后在执行git push origin master 看到数据在传输到远程仓库表示已经成功解决这个问题。

问题参考解决方案链接:https://blog.csdn.net/m0_37402140/article/details/72801372

目录
相关文章
|
存储 Shell Linux
git 大文件记录清除解决方案
git 大文件记录清除解决方案
5086 1
|
人工智能 运维 Linux
一文了解IntelliJ IDEA如何使用git上传代码到GitHub(附常见问题解决方案)
一文了解IntelliJ IDEA如何使用git上传代码到GitHub(附常见问题解决方案)
1068 0
|
安全 开发工具 git
git添加远程仓库报错To add an exception for this directory解决方案-优雅草卓伊凡
git添加远程仓库报错To add an exception for this directory解决方案-优雅草卓伊凡
1048 5
git添加远程仓库报错To add an exception for this directory解决方案-优雅草卓伊凡
|
Shell Linux 网络安全
宝塔服务器面板部署安装git通过第三方应用安装收费怎么办—bash: git: command not found解决方案-优雅草卓伊凡
宝塔服务器面板部署安装git通过第三方应用安装收费怎么办—bash: git: command not found解决方案-优雅草卓伊凡
1867 3
宝塔服务器面板部署安装git通过第三方应用安装收费怎么办—bash: git: command not found解决方案-优雅草卓伊凡
|
算法 安全 网络安全
git clone操作报错diffie-hellman-group1-sha1的解决方案
在处理这一问题时,需要确保了解相关操作的安全影响。`diffie-hellman-group1-sha1`算法被认为是不够安全的,这是因为随着计算能力的提高,`SHA-1`算法可以在合理的时间内被破解,而且其对应的 `1024位`Diffie-Hellman组也可能不够强大。因此,在确保Git操作的同时,也要考虑提升安全性的长期解决办法。强烈推荐与管理员或相关技术支持团队合作,升级和加强服务器端的安全配置。
449 12
|
API 开发工具 git
使用git pull遇到Automatic merge failed; fix conflicts and then commit the result.解决方案卓伊凡
使用git pull遇到Automatic merge failed; fix conflicts and then commit the result.解决方案卓伊凡
899 0
使用git pull遇到Automatic merge failed; fix conflicts and then commit the result.解决方案卓伊凡
|
持续交付 开发工具 git
如何保留原提交记录迁移Git项目,你还不知道吗?
如何保留原提交记录迁移Git项目,你还不知道吗?
如何保留原提交记录迁移Git项目,你还不知道吗?
|
开发工具 git Windows
【Git】warning: LF will be replaced by CRLF in .gitignore解决方案
warning: LF will be replaced by CRLF in .gitignore解决方案
|
开发工具 数据安全/隐私保护 git
git命令记录
git命令记录
257 1
git命令记录
|
开发工具 git Windows
使用git clone 遇见git did not exit cleanly (exit code 128)的个人解决方案
使用git clone 遇见git did not exit cleanly (exit code 128)的个人解决方案
3009 0
使用git clone 遇见git did not exit cleanly (exit code 128)的个人解决方案