web-dev-qa-db-fra.com

fatal: refus de fusionner des historiques sans relation après l'ajout de git remote

J'ai ajouté un référentiel distant au dossier dans lequel je travaille:

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

Si je tape:

git pull Origin master

Je reçois:

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

J'ai aussi essayé:

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

Mais je reçois:

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
13
ramab01

Vous devez d'abord reset ou commit vos modifications:

git reset --hard

ou:

git commit -m "saving changes..."

Ensuite, vous pouvez faire:

git pull Origin master --allow-unrelated-histories
45