[关闭]
@w1024020103 2017-02-13T17:56:17.000000Z 字数 1397 阅读 883

Git fatal: refusing to merge unrelated histories

git github cs61b


I was doing lab1 part D
Git and Remote Repositories

When doing Add the skeleton remote repository.
Instruction :

You will pull from this remote repository to get starter code for assignments. (Make sure that you are within the newly created repository folder when the continue with these commands.)

Enter the following command to add the skeleton remote.

git remote add skeleton https://github.com/Berkeley-CS61B/skeleton-sp17.git

Listing the remotes should now show both the origin and skeleton remotes.

$ git remote -v

So far things went on quite well.
7.JPG-45.2kB

Then, I moved the Working on the Skeleton

instruction:

You must now pull from the skeleton remote in order to get the starter code for lab 1. You will also do this when new projects and assignments are released. To do this, use the spookiest command in the whole git toolbox:

$ git pull skeleton master
What this does is grab all remote files from the repo named skeleton (which is located at https://github.com/Berkeley-CS61B/skeleton-sp17.git) and copies them into your current folder.

I did as the instruction, but I got an error:
fatal: refusing to merge unrelated histroties.

8.JPG-29.2kB

I searched the web for the answer, and found the following one working.
fatal: refusing to merge unrelated histories 解决方法
it says:

在github和本地分别建立了一个同名的项目
本地项目修改后commit是OK的,要push到github的远程仓库时候,先pull,出现如下错误:
fatal: refusing to merge unrelated histories
原因是两个仓库不同,所以要加上--allow-unrelated-histories
完整的语句是
git pull 远程仓库名称 远程仓库分支 --allow-unrelated-histories
I typed git pull skeleton master --allow-unrelated-historiesand it works just fine.

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注