How can I export my project directory in my local folder to Glitch?

Check out the title ^^^^^^^^^^

Hey @chroventer is this along the same lines as the question in Guide for Glitch Git?

Basically you’ll want to follow what Tim posted a while back in Possible to code locally and push to glitch with git?. In short:

  1. set a remote on a local git repository to point to your Glitch project’s repo, including the project’s git token. Both url and token available in the Advanced Options menu
  2. get the code you want to push on a different branch than master because git won’t allow you to push to master
  3. push your new branch
  4. in your project’s console, merge the new branch into master

There are some variations depending on whether you’re starting from a local copy of an exported project or are starting from scratch.

I plan on documenting this process in the help docs better but haven’t gotten to it yet.

There are no api methods that will allow you to upload code to a project, and no current plans to support that, although we may try to make it easier to upload projects in the UI some time down the road.

1 Like

Certainly, however, authentication seems to failing no matter if I provided it the correct information.

Can you give me the step-by-step detailed rundown of what you’re doing and what the actual response is? Also if you could share your project name so I can take a look that would be great (email to is fine)

1 Like

I managed to import the Glitch project to a local directory but how can I push to the Glitch project?

Ok, so assuming you have your project in a local git repo, here’s what you’ll need to do:

  1. Retrieve your project’s git repo url and your git token from the project’s advanced options menu. Here’s what that looks like:

  1. in your local repo add your project’s repo as a remote: git remote add origin https://{{put your git token here}}:@{{put your git url here}}. That’s using basic authentication with an empty password and your project’s repo url, so an example with a spoofed token might look like This allows you to authenticate to your project’s repo so you can push.
    1. if you cloned the repo you’ll already have an origin remote. In that case you want this command: git remote set-url origin https://{{put your git token here}}:@{{put your git url here}}
  2. As I noted above by default your project has the master branch checked out, so assuming you haven’t changed that you won’t be able to push to master - git will report an error if you do. So you need to move the code you want to push to a new branch before you can push it. In your local repo: git checkout -b my-new-branch
  3. Now you have something you can push. Assuming you’ve never pushed this branch before in your local repo: git push --set-upstream origin my-new-branch
  4. To get your new code live, in your project’s console: git merge my-new-branch. If you want to verify what you’re going to merge you can use git diff first.
  5. refresh in your project’s console to update the editor with the new changes.

Once you’ve got things set up you can just repeat steps 4-6 for all your local changes, except for step 4 you’ll want git push origin my-new-branch (you’ve already set up that branch to track the remote’s branch, so you don’t need --set-upstream. If you’re making changes in both places it’s a little more complicated because you’ll need to pull those changes down to get them locally:

  1. git pull origin master
  2. git merge master my-new-branch

will update my-new-branch with the changes in your project’s repo.

EDIT: updated image