This page covers the basics of using Git on your Squarespace site. For a more in-depth guide to using Git check out the Pro Git Book, which is available for free online at git-scm.com.
- Squarespace Developer Site
- Terminal application
Git is a version control system. It keeps track of the code you write on your site. Whenever you make a change, it is committed to your Git repository (even if you upload those changes through SFTP), which allows you to do things like access older versions of your site, or identify when a bug was created.
That depends on your workflow. Git can make a lot of things, like cloning a template to your computer, easier. And it can be a great way to manage the problems that occur when multiple people are editing code on one site. If you're a single developer working on a site, it may be easier to use SFTP to download and upload files.
Mac: There are several ways to install Git. One easy way is to use the graphic installer, which you can download here. Once the download is complete, open the .pkg file and follow the instructions to install it.
Once the install is complete, open up your Terminal application, type in the following command and hit enter:
If the install was successful, you should see a message that tells you which version of Git you are currently running, like this:
git version 22.214.171.124 (Apple Git-31.1)
To clone your template, log into your Squarespace site and go to the Developer tab. Under SFTP details there will be a line that says "Repository." Copy the URL listed there.
In your Terminal application, type in the following command and hit Enter:
git clone [your-repository.git]
You will get a prompt for your username and password. They are the same credentials you use to log into your Squarespace site. Once you type in your credentials, the template will begin downloading. This may take a few minutes.
Once you've made changes and you'd like to push them to your site, you'll need to type in a few more terminal commands. The first simply navigates to the folder where your files are stored.
Then you'll need to add the files you want Git to track for this commit.
git add site.region
Then you'll need to commit your changes. You can see in the command below that there is a space to add a message to each commit. These messages can be extremely helpful if you need to revert back to an older version of your code.
git commit -m "Changing something in site.region"
And, finally, push the changes to your site.