statamic / ideas

💡Discussions on ideas and feature requests for Statamic
https://statamic.dev
32 stars 1 forks source link

Ability to specify git branch #561

Closed stuartcusackie closed 3 years ago

stuartcusackie commented 3 years ago

Hey, first time using Statamic, and I just enabled Statamic Git today.

My client is working on content on their staging site before lauching to production. I've enabled git so that my local code changes don't overwrite their content changes.

I've just noticed that all code gets commited to main, even though the staging site (laravel forge) uses a dev branch. This is no big deal currently as I will be eventually turning off git on the staging site and enabling it on the production site.

I am a little concerned though...

What if in the future we have people working on content on staging and we would like to keep their content changes. I think I would have to enable git on both environments. Wouldn't this lead to dev branch code getting merged into main, when it's not ready for production?

So maybe a statamic git config variable to specify the branch would be useful? Or perhaps Statamic could just automatically detect the current branch from forge, or whatever is being used for deployments.

Thanks for listening.

stuartcusackie commented 3 years ago

Oops, just found this: https://github.com/statamic/ideas/issues/383

jesseleite commented 3 years ago

I've just noticed that all code gets commited to main, even though the staging site (laravel forge) uses a dev branch.

If forge is deploying using a dev branch, it should git push back to that dev branch as the currently checked out branch. Is it possible that you changed your deployment branch in Forge, but didn't update your deployment script, or vice versa?

image

This is no big deal currently as I will be eventually turning off git on the staging site and enabling it on the production site.

Think we're going to close this for now, as we don't want to over-complicate the git feature by encouraging diverging content branches. It could get messy if people start enabling git in multiple environments with push configured to different branches.

If you want people pushing content that is not ready for production, I might suggest they save their entries as drafts, or maybe even utilitize Statamic's revisions system 👍

stuartcusackie commented 3 years ago

@jesseleite Actually my forge deploy settings are both set to use 'dev'. Is this a bug then?

image

image

I think the draft / revision system you have suggested would be a pain to be honest and what @callum-veloxcommerce is suggesting would be much simpler. I think anyone who changes these settings in their config will be well aware of the repercussions. I could be wrong though.

jasonvarga commented 3 years ago

Is the dev branch checked out on the server? We're not explicitly pushing to master ever. It just uses what's checked out.

What does git branch --show-current output on the server?

stuartcusackie commented 3 years ago

Ah... I see. My forge deploys to dev, but git branch --show-current shows main.

I guess this is because the domain was originally set up on the main branch. I'll see if I can remedy that and I'll try again.

Thanks!

jesseleite commented 3 years ago

I guess this is because the domain was originally set up on the main branch. I'll see if I can remedy that and I'll try again.

That'd be my guess as well, thanks for clarifying!

stuartcusackie commented 3 years ago

Thanks guys!

A simple git checkout dev on my forge site solved it. Commits are now going to dev.

jasonvarga commented 3 years ago

Awesome!

jonassiewertsen commented 3 years ago

Just recently we did change all existing pages from the master to the main branch.

I can confirm that you need to checkout the new branch manually: