trilbymedia / grav-plugin-git-sync

Collaboratively Synchronize your Grav `user` folder hosted on GitHub, BitBucket or GitLab
Apache License 2.0
240 stars 58 forks source link

branch master -> FETCH_HEAD fatal: refusing to merge unrelated histories #168

Closed juliemar closed 4 years ago

juliemar commented 4 years ago

Hi I'm trying to test this plugin but I'm always receiving this message branch master -> FETCH_HEAD fatal: refusing to merge unrelated histories

gav version: 1.6 Plugin version: 2.1.0

image

w00fz commented 4 years ago

Have you seen here? https://github.com/trilbymedia/grav-plugin-git-sync/issues/39#issuecomment-546016249

DelphineLods commented 4 years ago

Hi ! I have the same problem. Did you find a solution ?

w00fz commented 4 years ago

Unrelated histories is supported by GitSync but only if your git version is greater than 2.9.0. I would advice you check and update the Git version on your system to resolve this.

rafvandevreugde commented 4 years ago

I have the same problem. I use git version 2.18.2 on Linux CentOS 8.1. In fact I have migrated the whole grav site to another Linux server. Trying to sync with gitlab gives the error: "branch master -> FETCH_HEAD fatal: refusing to merge unrelated histories" Deleting the webhooks and Access Tokens in gitlab and setting up a new one just result in the same error.

damionx7 commented 4 years ago

Run this command from user folder git pull --allow-unrelated-histories

https://stackoverflow.com/questions/37937984/git-refusing-to-merge-unrelated-histories-on-rebase

frunika commented 4 years ago

Running grav v1.6.26 and Git Sync v2.1.0 and I ran into the same issue. As mentioned by @damionx7 one solution is:

git pull origin master --allow-unrelated-histories

But you need to have shell access on the webserver.

rvreugde commented 4 years ago

Indeed, this works. Thanks!

paulhibbitts commented 4 years ago

Hi @w00fz , I am now also running into this error with fresh installs on a new cloud hosting platform I am testing. Are you saying that the min Git version for using Git Sync is now 2.9.0 or is there a way for me to avoid this error with earlier versions of Git?

UPDATE: Looks like I have Git version 2.25.1

UPDATE #2: Poking around the plugin issues, I tried git pull origin master --allow-unrelated-histories and after that I was able to sync! Is this what you could recommend?

w00fz commented 4 years ago

I am just baffled as to why so many of you guys see this issue when I have clearly a check for the version that should be doing exactly what you did:

https://github.com/trilbymedia/grav-plugin-git-sync/blob/develop/classes/GitSync.php#L348-L362

My only suspect is that the git binary that GitSync uses (specified in the configuration as just git by default), is not the same git binary that you are using in command line.

paulhibbitts commented 4 years ago

Hi @w00fz , thanks for the update. I've got a fresh install with this exact issue and would be happy to give you shell access/screen share session to look or I could try to get any info you want - please let me know if that would help.

Thanks very much, Paul

w00fz commented 4 years ago

Hey everyone, I finally got to the bottom of this issue and it appears a regression was introduced where the method returning the git version would always return true instead of the actual version.

Because the version check is necessary to ensure certain git features get enabled (like allow-unrelated-histories), the regression would prevent that from happening.

I have now fixed this and @paulhibbitts kindly helped testing this confirming it's fine. A new release v2.1.1 is out and you shouldn't be needing manually running the command from terminal anymore, as long as your git version is > 2.9.0 (which is fairly old now).

Thank you everyone for helping determining what the issue was and helping each other with workarounds!

belloshehu commented 2 years ago

Wow! It worked.

Thanks