Use Visual Studio Code (VSCode) to edit web-apps hosted on Glitch.
Head over to Glitch.com and set up an account. We recommend setting up and linking a GitHub account.
Click New Project
and follow the wizard to create a new website project with a random name.
Your website is now live! You can navigate to it in a browser. Don't worry about the name. We'll show you how to
change it later.
Edit your project. Note how changes you make to the code in editor take effect immediately. You can even change the name (and URL) of your project in the editor right now, without having to make any changes in VSCode.
You can make cool web-apps using only the editor, but we're going to connect it to VSCode now.
VSCode supports, but is not bundled with, Git. Download and install them separately.
There will be additional installation steps on Windows to get VSCode and Git working together.
Ubuntu is currently the most popular Desktop Linux distribution, making installation in Ubuntu Linux easy. Installation in different Linux distributions will be slightlyy different. I will outline two methods:
Two commands:
snap install code
apt install git
Or:
VSCode can be installed via the Snap Store (titled 'Ubuntu Software').
Note: You will still need to install Git using the terminal.
Find Tools
in the Glitch Editor.
Click Import, and Export
, then copy
the contents of Your project's Git URL:
.
In the next step, you will use this URL in VSCode.
File - Open Folder
Git commands can be run from VSCode's Command Palette, an intelligent command line. The
default keyboard shortcuts for the Command Palette are CTRL-shift-P
or F1
Launch the Command Palette, type Git Clone
and when prompted, enter the Repository URL you
copied from Glitch.com, and press enter. You will then get to choose the folder your project's git
repository gets cloned to.
You should now be working on a clone of the 'master' branch. As shown in the bottom-left of VSCode.
Try not to edit the local master branch because by default, you won't be able to push it back to the server to override the live version. (However, there are instructions on how to enable this below.)
Instead, create a new branch by:
Git: Create Branch
in the Command Palette, orCreate New Branch
.
Note: You will immediately 'checkout' and start working in your newly created branch. Confirm by looking at the bottom left of VSCode.
Before you start editing code, there are some VSCode extensions you can install that will make life a lot easier, namely:
Go Live
launches a local web server and
directs a web
browser tab to it so that you can test your code locally.Now, make some edits in VSCode. Coming up next: how to push those changes to your live website.
This involves pushing your new local branch to the remote then using the command-line to merge the remote copy of your new branch into the master. A simpler method involving editing the master branch directly is outlined below.
Enter VSCode's Source Control section to see a list of changed files ready for staging.
The fastest way to stage and commit your changes is to:
✔
.…
and choose Push
.Your new branch should now have been pushed to Glitch
The final step to making your changes live is to merge your branch with the master branch on the remote/origin server.
Tools - Terminal
to open a command-line.git merge name-of-your-branch
.refresh
to refresh your projectNot only are the changes to your website live, but they will also be visible in the Glitch Editor.
Although the more indirect method outlined above is preferable, This simpler method is good if you have:
Note: You can work in both your master and a new branch, but beware confusion.
Tools - Terminal
to open a command-line.git config receive.denyCurrentBranch updateInstead
.As previously mentioned, Git on Glitch does not allow changes to be pushed to master by default . This changes that setting.
Enter VSCode's Source Control section to see a list of changed files ready for staging.
The fastest way to stage and commit your changes is to:
✔
.…
and choose Push
.Your master branch should now have been pushed to Glitch
The final step to making your changes live is to reset Git.
Tools - Terminal
to open a command-line.git reset --hard
.refresh
to refresh your projectIf you have made subsequent changes in the Glitch Editor, you will want to pull them into VSCode and synchronise your code.
…
.Pull
.Pull from
, select
origin
, then select origin/master
.F1
or
CTRL-shift-P
) and type Git: Pull
or Git: Pull from
'Rename' could mean two things:
They're both simple, and will be covered in one go.
git
subfolder within your code folder.Glitch will often give your new project a random name and matching URL. You can change it any time in Glitch. However, since the URL of the remote Git repository will also change, you will need to reconfigure Git.
Tools
, then Git, Import, and Export
.Copy
the Read
URL..git
subfolder (it may be in the
git
subfolder).config
file in a text editor and replace the url
value with the URL you
just copied.e.g. old config file snippet:
[remote "origin"] url = https://api.glitch.com/workable-tangerine/git
new config file snippet:
[remote "origin"] url = https://api.glitch.com/new-project-name/git