Possible to code locally and push to glitch with git?

#1

Like heroku dev cycle?

Can glitch keep synced with a git repository?

0 Likes

#2

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

Control via VSCode
#3

Updated to use the new Git access tokens:

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/wealthy-tv/git
git clone https://<git access token>@api.glitch.com/wealthy-tv/git

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/my-project/git 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.

11 Likes

Code locally, push to glitch via git?
Best methods for git in glitch
My machine will not `git push`?
Unable to git clone
Get the container/Docker image of my glitch app
Unable to export private project to local repo
How can I export my project directory in my local folder to Glitch?
Export a local directory to Glitch
Export directly to Glitch
#4

Is it possible to automate the merge?

Possibly within the node app I’m guessing?

0 Likes

#5

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

0 Likes

#6

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

0 Likes

#7

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?

0 Likes

#8

Tim describes it in a reply to this thread.

0 Likes

#9

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.

7 Likes