15
votes

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
1
Are you starting the new repository? - max630
technically yes because it didn't find the repository that I was working . SO i typed this : ``` git remote add origin github.co/username/xxxxx.git ``` - ramab01
git pull origin master --allow-unrelated-histories .See here stackoverflow.com/questions/37937984/… - Bhargav Variya

1 Answers

52
votes

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