尝试从我的Github存储库中提取文件:“拒绝合并不相关的历史记录” [英] Trying to pull files from my Github repository: "refusing to merge unrelated histories"

查看:316
本文介绍了尝试从我的Github存储库中提取文件:“拒绝合并不相关的历史记录”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在学习git,我正在关注Git社区书。

以前(很久以前)我在Github上创建了一个公共仓库,并附带一些文件。现在,我在当前的计算机上建立了一个本地Git存储库,并提交了一些文件。然后,我添加了一个指向我的Github页面的远程指针:

  [root @ osboxes c]#git remote add learnc https:// github.com/michaelklachko/Learning-C 

这似乎是成功的:

  [root @ osboxes c]#git remote show learnc 
* remote learnc
抓取网址:https://github.com / michaelklachko / Learning-C
推送网址:https://github.com/michaelklachko/Learning-C
头部分支:主人
远程分支:
追踪的主人
为'git push'配置的本地ref:
主人推送给主人(本地过期)

现在我想从我的Github仓库下载文件到我的电脑。我做到了这一点:

  [root @ osboxes c]#git fetch learnc 
[root @ osboxes c]#git合并learnc / master
警告:refname'learnc / master'含糊不清。
已经是最新的。

但是,我在本地目录中看不到任何新文件。我怎样才能得到它们?



我也试过这样做:

  [root @ osboxes c]#git pull learnc master 
从https://github.com/michaelklachko/Learning-C
* branch master - > FETCH_HEAD
fatal:拒绝合并不相关的历史

顺便提一下,我在master分支(没有其他分支机构):

pre code $ [root @ osboxes c]#git status
在分支master $ b上$ b没有提交,工作目录干净


解决方案

code> - allow-unrelated-history



像max630评论过的,或者如拒绝合并无关的历史


I'm learning git, and I'm following the Git community book.

Previously (long time ago) I made a public repository on Github, with some files. Now I set up a local Git repository on my current computer, and committed some files. Then I added a remote pointing to my Github page:

[root@osboxes c]# git remote add learnc https://github.com/michaelklachko/Learning-C

That seemed to be successful:

[root@osboxes c]# git remote show learnc
* remote learnc
  Fetch URL: https://github.com/michaelklachko/Learning-C
  Push  URL: https://github.com/michaelklachko/Learning-C
  HEAD branch: master
  Remote branch:
    master tracked
  Local ref configured for 'git push':
    master pushes to master (local out of date)

Now I want to download the files from my Github repo to my computer. I did this:

[root@osboxes c]# git fetch learnc
[root@osboxes c]# git merge learnc/master
warning: refname 'learnc/master' is ambiguous.
Already up-to-date.

However, I don't see any new files in my local directory. How can I get them?

I also tried to do this:

[root@osboxes c]# git pull learnc master
From https://github.com/michaelklachko/Learning-C
 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories

BTW, locally I'm on master branch (there are no other branches):

[root@osboxes c]# git status
On branch master
nothing to commit, working directory clean

解决方案

Try --allow-unrelated-histories

Like max630 commented, or as explained here Git refusing to merge unrelated histories

这篇关于尝试从我的Github存储库中提取文件:“拒绝合并不相关的历史记录”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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