How to manually/locally update theme with Git/Visual Studio Code

I have setup my theme (Crave) with two Git branches (dev and release) which are connected with shopify. So I make changes to the theme locally with Visual Studio Code and then commit them to the remote repo on github.

Crave now got updated and I want to integrate that update, but I’m still quite new to this kind of workflow (I’m not a pro in terms of “programming”). How would I go about that integration without losing my changes on the theme?

This is how I think I should do it but I need some hints so that I don’t mess up (altough I guess I could merge the current master branch back to dev if I mess up?).

  1. Download the newest theme zip
  2. Unpack the zip and copy all files into my local repo (overwrite)
  3. Go through all the changes in the version control in Visual Studio Code and make sure that my previous changes get merged into the updated theme files
  4. Commit/Push and test it, if everything is ok, merge dev branch with release branch to get the updated theme live

Any pitfalls, hints, things to consider? Thank you!

I have a similar question for Dawn theme. It got update to version 7.0.0 and my local branch is on version 6.0.2. How to I update my branch to 7.0.0 without loosing my changes

I wanna use VS Code to edit theme too.

I don’t have much experience in using command.
Can any expert provide the steps (in point form) for me to follow inputting in the teminal of VS Code to use git?

This show my final result, no respository is being setup.

Did you find the answers you needed? Currently running into this same issue.

I’m not too far into my project yet but I did one big theme update the way I stated in my original post. It was fine for the most part since I haven’t done much custom code. But the main issue was this:

I copied the newest theme files over my local repo and altough I could check the changes with the version control of VS Code, I got into trouble on lines of code where I changed something and at the same time the theme devs changed and added code.

Like the noob I am I didn’t understand why I couldn’t merge my change with the dev’s change. The reason of course would be, since I copied the theme update over my local repository, ALL changes are considered MY changes. The version control difference editor just compares my local repo with the last commit on git. So in order to keep the code additions from the dev’s and say my changed values I would have to manually change it for the next commit. Obviously this isn’t the way…

I haven’t tested it yet but here is a system I came up with that I wanna try for next time:

I’ll create an additional branch just for theme updates. So these would be my branches:

  • release
    • The currently published, live version of the theme
  • dev
    • Unpublished theme repository I work on, where I add/change stuff, test it and eventually merge/overwrite with the release branch when it’s ready
  • update
    • Whenever a theme update is released, I copy the complete repo (content of the downloaded theme zip) into the update branch (completely replace the one from before). Then I merge the update branch with the dev branch. By merging branches we get to compare with the merge editor instead of the difference editor. NOW when there are conflicts on a line of code, I’ll get to decide if I want to keep the code as it is on my dev branch, replace it with the code of the theme update OR merge the two if possible

A few tipps I gathered from other posts to identify what code is custom code I made and what’s from the updated theme code:

  • Use snippets wherever possible. This way I know, where there are render tags, it’s probably a snippet I added
  • Use comments to mark custom code
  • Make copies of the themes sections, templates etc. you wanna customize and name them with your own naming convention
    • Be aware that this way you won’t get updated code the theme’s dev make on the original files
  • Use your own naming convention for classes, metafields etc. to easily identify your custom additions and changes

Thank you so much for taking the time to write this response - super helpful! One thing I don’t fully understand is how to create the “update branch”. When you make a branch you have to give it the source branch and then that branch is just a duplicate of the source. How do you make this new branch totally different files?

Good point! I was dabbling with ChatGPT recently and I presented my theme update process together with your question. I haven’t tested ChatGPT’s answer yet, but here is its suggestion (the list numbers count got messed up by copy/paste):

To create a new branch with different files, you can clone the entire repository into a new directory and checkout a new branch in the cloned repository.

Here are the steps to create an “update” branch:

  1. Clone the repository: Use the “git clone” command to clone the entire repository into a new directory. For example, if the repository is hosted on GitHub, you can run the following command:

git clone [https://github.com/[username]/[repository-name].git](https://github.com/[username]/[repository-name].git)

  1. Checkout a new branch: Change to the cloned repository directory and checkout a new branch using the “git checkout” command. For example, to create an “update” branch, you can run the following command:

cd [repository-name] git checkout -b update

  1. Remove the theme files: Delete the theme files from the cloned repository directory. You can use the “rm” command to delete the files.

  2. Add the updated theme files: Copy the updated theme files into the cloned repository directory.

  3. Commit changes: Commit the changes to the “update” branch using the “git commit” command.

  4. Push the branch: Push the “update” branch to the remote repository using the “git push” command.

I think, this makes sense. If you happen to test this approach, keep us posted.

From the release branch do

git merge dev