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

Local Branch and Remote Branch mislabeled #98

Closed 1aurabrown closed 6 years ago

1aurabrown commented 6 years ago

Unless I misunderstand what 'Local' and 'Remote' refer to in the plugin settings, I believe that in the Plugin settings interface, Local Branch actually affects which branch on github.com is used for syncing, and Remote Branch refers to the branch on the server. I discovered this because I wanted to sync the production instance of my app with a branch in the repo called 'production' and sync the staging app with master. Entering this according to the labels resulted in an error stating that the remote branch at my repot on github could not be found. However when I inverted the entries, it worked. I certainly don't have a local branch on heroku called 'production', and I definitely do on github. I havent looked at the code, but it seems obvious that the branch names are getting pulled from the wrong fields/the fields are mislabeled.

screen shot 2018-06-07 at 7 14 33 pm

w00fz commented 6 years ago

Local Branch is supposed to refer to where you have your Grav instance with GitSync installed. In there you cloned your git repository and possibly changed the branch to something else (ie, production).

origin/master is the remote where your changes will be pulled from and pushed to.

So if I am picturing correctly your setup, on heroku you should be using a production branch and if you make changes in Grav, they get pushed in github to origin/master.

Is this not what is happening?

1aurabrown commented 6 years ago

Hmm maybe I am confused. I want the opposite to happen--I don't need multiple branches on heroku, I have two separate apps for staging and production set up there. I want one repo on github with two branches -- one which syncs with the staging app, and one which syncs with production app.

Can this be done?

1aurabrown commented 6 years ago

With these settings I receive this error: screen shot 2018-06-07 at 7 54 54 pm screen shot 2018-06-07 at 7 54 47 pm

w00fz commented 6 years ago

It can, I think what you want is:

  1. Loca Branch: production
  2. Remote Name: origin
  3. Remote Branch: production
w00fz commented 6 years ago

Also keep in mind that you want to make sure you are in the right branch on heroku. Go in the user folder of Grav and via CLI run a git branch to see which is selected.

1aurabrown commented 6 years ago

@w00fz thanks for the help. Is there any reason I can't use master on heroku?

w00fz commented 6 years ago

You can use master. Master is just another branch, the point is that you need to setup gitsync to match both the remote and local branching you have. Usually this is master, origin, master. I guess I'm trying to understand how your setup is because it's not entirely clear to me.

I'm going to shoot a few questions your way:

  1. Heroku has the Grav installation with GitSync installed, correct?
  2. You checked out your repository which is now the user folder under the Grav installation, what is the branch setup in there? master or production?
  3. Github is where all your codebase is, including all the branches, do you have both master and production branches there?
  4. When you go in Grav Admin and save a page change, where are you expecting it to go to? master or production?

Also just so it is clear: Heroku = Local Github = Remote

Even though from both yours and mine perspective they are both remote. But they are local and remote from Grav / GitSync perspective.

1aurabrown commented 6 years ago

Hi again and thanks for the help!

I don't think heroku supports git on their servers other than providing a remote to push to for deploy. For this reason, both apps on heroku are always on their local 'master' (or at least it returns to master each time the app re-starts). I wanted them each to be able to sync to a separate branch of a single git repo (remote), ie 'master' and 'production, or 'staging' and 'production'.

In practice it is probably sufficient to only sync the production app, between local 'master' and remote 'master', so this is a fine solution for now.

Another complication of heroku's ephemeral file system is that each time the web app is restarted, it returns to the state it was in at last deploy--this means any changes to the file system which were not present in the deployed commit are reverted. Therefore it is necessary to persist changes to the user folder elsewhere, for example on github. I hadn't thought about this before releasing the app on heroku, and I am wondering what other people's solution has been, or if git sync is the best option.

Thanks! Laura