Possible to code locally and push to glitch with git?

Like heroku dev cycle?

Can glitch keep synced with a git repository?

1 Like

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.


I didn’t see any button says copy token, I just see the button say copy username, but when I click it only give null

Have a look on this, this gives you an example on how to get a hold of your Glitch token, if that is what you’re trying to achieve Simple way of updating code on VPS from glitch

git config receive.denyCurrentBranch updateInstead worked great for me!

I also found a way to automate the refresh command with a post-receive hook. This command in the console should do it, from your home directory (which is where you start by default):

echo refresh > .git/hooks/post-receive && chmod u+x .git/hooks/post-receive

This simply adds a file containing the line “refresh” (to make a script that calls Glitch’s refresh command) at .git/hooks/post-receive, which is a special script that Git will call after receiving updates. So after receiving the push, it will call the refresh command and reload the app with your changes automatically. I tested it out on one of my repos and it seems to work great!

1 Like

I did something similar in the making of my Glitch CI script. If only people knew about git hooks :stuck_out_tongue: