Possible to code locally and push to glitch with git?

Like heroku dev cycle?

Can glitch keep synced with a git repository?

Yes. There are GitHub import/export options in the menus, but if you know what you’re doing with git you can do much more. Your container already contains a git repository, and you can run git commands from the command line, so you could set a remote and push to it from there. Glitch doesn’t automatically sync with a remote repo right now, so you would have to manually run the commands, or write some code in your project to push/pull regularly.

1 Like

Updated to use the new Git access tokens (and later to reorder the URLs):

I think I read this backwards the first time. You can do most of what you want right now. Go to the Advanced Options menu in your project, and you’ll find the Git URL for your project, and a button that will copy your secret Git access token. You’ll be able to clone public projects with just the URL, but the token is needed to access private projects, and to get write access through Git.

If you want to push to Glitch, you can use command line tools to access your project from outside. You can use the first URL if you want read-only access.

git clone https://api.glitch.com/git/wealthy-tv
git clone https://<git access token>@api.glitch.com/git/wealthy-tv

Because the git repo in the container has a working directory, you can only push to it if your code is on a branch, so the workflow for pushing changes from the command line is git clone, create a branch, make changes, push:

git clone https://api.glitch.com/git/my-project my-project
cd my-project
git checkout -b mybranch
<make code changes and commit>
git push (the first time you’ll need “--set-upstream origin mybranch”, but git will remind you)

You can then go the console inside the Glitch project to check the changes and merge them:

git diff ..mybranch
git merge mybranch
refresh (so that editor updates)

Again, there is the manual step of merging in the project, but this gets you most of the way there.


Is it possible to automate the merge?

Possibly within the node app I’m guessing?

Yes, you could run the merge command from inside the app.

More discussion here: Code locally, push to glitch via git?

When i try to git push i get asked for a password. Since i “Log in with github” to glitch, i don’t think i have a password, do you know if there’s a standard one?

Tim describes it in a reply to this thread.

I solved it in the following way:

  1. go to the Glitch console and change the denyCurrentBranch parameter
    git config receive.denyCurrentBranch updateInstead

  2. Then you can push without any issues and undesirable consequences.

  3. Note that you still need to refresh your Glitch project manually in the console, using the refresh command.