trilbymedia / grav-plugin-git-sync

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

Setting up Plugin gives Git error #38

Closed jaygorrell closed 6 years ago

jaygorrell commented 7 years ago

This is essentially a vanilla Grav setup with Admin+GitSync. I have a repo that contains only the user directory contents, which I believe is how this plugin expects it to be. Plugin configuration is standard. Upon saving the settings I get the following:

screenshot 2017-04-17 21 11 19

The only thing potentially noteworthy is that I did not add the webhook to my repository because I only want one-way syncing. If changes happen in Github they will go through my deployment pipeline and get deployed properly anyway with a new image.

Because of this process, I also know no local files are modified. I did log into the instance and am able to manually re-run the failed git command:

git pull -X theirs origin master
From https://github.com/PotomacInnovation/marketing-grav
 * branch            master     -> FETCH_HEAD
error: The following untracked working tree files would be overwritten by merge:
    plugins/admin/blueprints/admin/pages/modular_new.yaml
    plugins/admin/blueprints/admin/pages/modular_raw.yaml
    plugins/admin/blueprints/admin/pages/move.yaml
    plugins/admin/blueprints/admin/pages/new.yaml
    plugins/admin/blueprints/admin/pages/new_folder.yaml
    plugins/admin/blueprints/admin/pages/raw.yaml
    plugins/admin/pages/admin/ajax.md
    plugins/admin/pages/admin/backup.md
    plugins/admin/pages/admin/cache.md
    plugins/admin/pages/admin/config.md
    plugins/admin/pages/admin/dashboard.md
    plugins/admin/pages/admin/denied.md
    plugins/admin/pages/admin/feed.md
    plugins/admin/pages/admin/forgot.md
    plugins/admin/pages/admin/info.md
    plugins/admin/pages/admin/installer.md
    plugins/admin/pages/admin/login.md
    plugins/admin/pages/admin/logout.md
    plugins/admin/pages/admin/media.md
    plugins/admin/pages/admin/notifications.md
    plugins/admin/pages/admin/pages-filter.md
    plugins/admin/pages/admin/pages.md
    plugins/admin/pages/admin/plugins.md
    plugins/admin/pages/admin/register.md
    plugins/admin/pages/admin/reset.md
    plugins/admin/pages/admin/site.md
    plugins/admin/pages/admin/statistics.md
    plugins/admin/pages/admin/system.md
    plugins/admin/pages/admin/themes.md
    plugins/admin/pages/admin/tools.md
    plugins/admin/pages/admin/update.md
    plugins/admin/pages/admin/user.md
    plugins/admin/themes/grav/app/pages/filter.js
    plugins/admin/themes/grav/app/pages/index.js
    plugins/admin/themes/grav/app/pages/page/add.js
    plugins/admin/themes/grav/app/pages/page/delete.js
    plugins/admin/themes/grav/app/pages/page/disable-buttons.js
    plugins/admin/themes/grav/app/pages/page/index.js
    plugins/admin/themes/grav/app/pages/page/media.js
    plugins/admin/themes/grav/app/pages/page/move.js
    plugins/admin/themes/grav/app/pages/page/multilang.js
    plugins/admin/themes/grav/app/pages/tree.js
    plugins/admin/themes/grav/templates/forms/fields/pages/pages.html.twig
    plugins/error/pages/error.md
    plugins/login/pages/forgot.md
    plugins/login/pages/login.md
    plugins/login/pages/register.md
    plugins/login/pages/reset.md
Please move or remove them before you can merge.
Aborting

None of these files are modified of course, but the more strange question to me is why only these in the error? Why not all the other files under plugins/error/? Since I'm using a standard setup, I'm wondering what is missing here.

w00fz commented 7 years ago

What version of Git are you running? it has to be > 1.7.1

cpannwitz commented 6 years ago

Hey, actually having the same problem. @jaygorrell did you solved this by any chance? We have git version 2.7.4 on server, and (almost) the same error message appears on saving a page. There's also another error on the plugin page: "On branch master Untracked files: .gitignore .gitkeep accounts/ blueprints/ config/ plugins/ themes/ nothing added to commit but untracked files present"

The local repo is set to "master", the remote repo is set to "final", which is the branch we want to sync with. Why does the plugin errors out on plugin and blueprint things, even though it only appears to sync the pages folder?

mlanser commented 6 years ago

Hello, it seems I have a similar issue w git-sync. Did you guys ever resolve this? Btw, when I run git straight from command line (i.e when I use "git pull ..." etc.), then everything seems fine -- no conflicts, nothing. I only get this error when I use git-sync.

Here are the files that seem affected:

Any ideas?

TIA, -martin.

jaygorrell commented 6 years ago

@cpannwitz sorry I missed your reply months ago.

@mlanser We did get it working but I have no idea why it required custom changes. Basically we had to tell git to ignore certain files using something like this (in our Dockerfile).

git ls-files -z themes/ | xargs -0 git update-index --assume-unchanged

You may need to adjust the folders but this worked for us -- basically tell git-sync to only monitor expected pages. We also have it ignoring other files mounted at runtime (Docker/Kubernetes environment).

mlanser commented 6 years ago

@jaygorrell Thanks! I will try this and will see how far I get. The thing is, I have 3 diff Grav sites with identical config, etc. and GitSync says it's 'ok' on 1st, shows warning on 2nd, and error on 3rd. And for both 2nd and 3rd site it points to standard Grav folders that are marked as 'ignore' in the .gitignore file. Furthermore, all 3 sites show no issues when I run git from terminal ... so I guess it's a bit of a mystery.

cpannwitz commented 6 years ago

Ah well, thats from some time ago. I'm remembering as well having to delete/move/ignore certain files and branches, to get this thing to work. I think basically the problem was, that we didn't initialize the branch (?) with the plugin (?), so it broke when it found some already existing stuff, which should't be a problem, since those files were the same.

But anyways, we moved away from Grav.

mlanser commented 6 years ago

OK ... figured it out! I must have missed this somewhere in the instructions, but the trick seems to be that one has to start with a new/empty git repo. If you do that then GitSync only syncs 'user/pages' and it works just fine. I now have 2 repos: one for the Grav site itself where I manage custom plugins, themes, etc., and another for 'user/page'. And, of course, my '.gitignore' files ensure that I don't end up with overlapping repos.