Skip to main content

Understanding version control before you edit your theme

A non-technical explainer of what version control is, why it matters, and what to do, for a customer who has been asked to add the Tie Pixel loader to theme.liquid and has never edited theme code before.

T
Written by Tim Hughes

Installing the Tie Pixel on Shopify means adding one line to your theme's code. If you have never edited theme code before, that can feel like a point of no return. It is not, and the reason is version control.

What version control is

Version control is a record of every saved change to a file. Each time someone saves, a copy of what the file looked like at that moment is kept, so the file's history stays available instead of being written over.

You have almost certainly used it already. Version history in Google Docs is version control. You can look at what the document said before today's edits, see what changed, and put it back the way it was. Editing code works the same way. Your change creates a new version. It does not replace the only copy that exists.

Why it matters when you edit your theme

Your theme is what builds your storefront, so an edit that goes wrong is an edit shoppers can see. Version control is what turns that from a risk into an inconvenience. Three things it gives you.

  • A way back. If a change causes a problem, you restore the version from before it. You do not have to remember what was there or retype anything.

  • A record of what changed. Themes get touched by a lot of hands, including yours, your agency's, your developer's, and any app that edits theme code when you install it. The history is how you find the cause when your storefront looked right yesterday and does not today.

  • A reason not to wait. Knowing a change is reversible is usually what decides whether it happens now or sits in someone else's queue.

How Shopify does this for you

There is nothing to set up. Shopify's theme code editor keeps a history of saved versions for each file in your theme, including theme.liquid. Open the file from Online Store, then Themes, then Edit code, and you can view its earlier versions and restore one.

Restoring is itself a save, so the restored file becomes the newest version and the history keeps going. You are never picking between two permanent options.

If your theme is connected to GitHub

Some stores keep their theme in a GitHub repository, which is usual when a developer or an outside agency maintains it. If that is your setup, the repository is where your theme's real history lives, and it is a richer record than the file history in Shopify, because every change there carries a note about what it was for.

A connected theme stays in step in both directions, with nobody having to remember. A change saved in Shopify is committed to the connected branch for you, and a change pushed to that branch updates your theme. Your edit is recorded either way, and it becomes visible to whoever maintains the repository.

Find out whether your theme is connected before you edit it. If it is, ask whoever maintains it where they want the change made, and do not work in a file at the same time they are. Shopify warns you when you are about to save over someone else's changes, and that warning is easy to click past without reading.

To go back on a connected theme, use the repository's history rather than the file history in Shopify.

What you need to do

  1. Check whether your theme is connected to a GitHub repository. If it is, talk to whoever maintains it before you change anything.

  2. Check which theme you have open. The code editor works on whichever theme you chose, and only your published theme affects what shoppers see.

  3. Add the Tie Pixel loader where your install instructions tell you to, and save.

  4. Look at your storefront in a normal browser window and confirm it looks the way it did before.

  5. If anything looks wrong, restore the previous version. Open that file's version history, or your repository's history if the theme is connected, and pick the version from just before your edit.

If you would rather not touch your published theme at all, duplicate it first, make the change on the duplicate, and publish that only once you are happy with it. Your published theme stays exactly as it is until you decide to switch.

What does not happen

Adding the loader does not change your theme's design, your product pages, or your checkout. It does not overwrite anything, because the previous version stays in your theme's history. And it is not a one way door. Everything described here is something you can undo yourself.

Did this answer your question?