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

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 https://xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:@api.glitch.com/anonymous-anaconda/git. 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 ..my-new-branch 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