如何解决“拒绝合并不相关的历史”当上传项目到github? [英] How to fix "refusing to merge unrelated histories" when uploading project to github?

查看:295
本文介绍了如何解决“拒绝合并不相关的历史”当上传项目到github?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows机器上安装了Github桌面和git,我有一个github帐户并创建了一个虚拟存储库。

当我打算通过git bash命令行上传我的包时,它失败并显示错误:
致命错误:拒绝合并不相关的历史记录



我通过使用该社区的现有解决方案,使用多种方法来解决此问题,但仍未解决问题。有没有人知道解决这个问题的技巧?

解决方案

请尝试以下操作:

  cd / path / to / my / repo 
git init
git add --all
git commit -m初始提交
git remote add origin< remote repo URL>
git push -u origin master

请务必将 / (例如 C:\ Users \jvrat\Documents\MSPC )路径/ to / my / repo <远程回购网址> ,以及您的远程回购网址(例如 https://github.com/username/repo_name.git )。


I have installed Github desktop and git on windows machine, I got a github account and created a dummy repository.

When I intend to upload my package through git bash command line, it fails with error: fatal: refusing to merge unrelated histories

I used several ways to overcome this issues by using existing solution from this community, but still didn't fix the problem. Does anyone know any trick of working this problem? How can I upload my projects to github successfully?

解决方案

Try the following:

cd /path/to/my/repo
git init
git add --all
git commit -m "Initial commit"
git remote add origin <remote repo URL>
git push -u origin master

Be sure to replace /path/to/my/repo with path to your repo directory(e.g. C:\Users\jvrat\Documents\MSPC), and <remote repo URL> with URL to your remote repo (e.g. https://github.com/username/repo_name.git).

这篇关于如何解决“拒绝合并不相关的历史”当上传项目到github?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆