Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fatal: refusing to merge unrelated histories after adding git remote

Tags:

git

github

I've added a remote repository to the folder where I am working with :

git remote add origin https://github.com/<username>/<repo>.git

If I type:

git pull origin master

I get:

From https://github.com/<username>/<repo>
    * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories

I have also tried:

$ git pull origin master --allow-unrelated-histories

But I get:

From https://github.com/...
    * branch            master     -> FETCH_HEAD
error: Your local changes to the following files would be overwritten by merge:
    <files>
Please commit your changes or stash them before you merge.
Aborting
like image 313
ramab01 Avatar asked May 01 '18 03:05

ramab01


1 Answers

You need to either reset or commit your changes first:

git reset --hard

or:

git commit -m "saving changes..."

Then you can do:

git pull origin master --allow-unrelated-histories
like image 161
Fernando Espinosa Avatar answered Oct 20 '22 10:10

Fernando Espinosa