Really Simple Staging preserving .data and .env

I am developing an application using glitch. I would like to be able to push it from a dev copy to a demo copy, and then to production manually. I understand I could probably export to github and build workflows and CI to do all this, or develop using an ide on my laptop. I also read a similar forum post where they landed on swapping out project names. But I like to stay in the web editor, and swapping project names ignores the .env and .data folders, which need to stay. What I really want is:

  • develop foo-dev in the web-based glitch editor.
  • open the web based terminal and run one command (or a shell script I write) to push all of the code, but NOT .env or .data to foo-demo or foo-prod.

I am able to get close if I:

  • ensure .env and .data are in .gitignore
  • from foo-dev terminal “git commit”
  • from foo-demo terminal “git remote add dev https://path-to-foo-dev/git/foo-dev.git” once, then as-needed “git pull dev master --no-edit” and “refresh”

However, this requires me to touch both foo-dev and foo-demo each publish. I’d really like to push. When I try this:

  • from foo-dev terminal “git remote add demo https://path-to-foo-test/git
  • from foo-dev terminal “git commit” and then “git push demo master -f”

I get an error “refusing to update checked out branch”.

Thanks to SO, I was able to get around this with git config receive.denyCurrentBranch updateInstead from the foo-demo terminal.

But when I do this, as best I can tell, foo-demo never gets updated. I’m sure there’s something I’m missing - I’m beyond my basic understanding of git here. But in the end: Is there some easy way to push code from one project to another, without involving github or laptop, taking care to not overwrite .data and .env?

the last step is probably to run refresh on foo-demo so that glitch relaunches the project with the new code. maybe you could do it with a git hook of some sort in foo-demo.

can you look up what git hooks the version of git on glitch supports?

Still needs some testing, but that pointed me in the right direction. I didn’t know about git hooks at all.

On the receiving project terminal, run:

git config receive.denyCurrentBranch updateInstead 
echo 'refresh' > ./.git/hooks/post-update
chmod +x ./.git/hooks/post-update

Then when it’s pushed into, the project refreshes. Exactly what I want - I just need to test some more to see if there are any gotchas.

1 Like