How can I use Git(Hub) to make changes on my local (Wamp) and push these changes to live?

<%- if @topic_view.topic.tags.present? %>
<%= t 'js.tagging.tags' %>: <%- @topic_view.topic.tags.each do |t| %> <%= t %> <%- end %>
<% end %>

Silverstripe 4.5
How can I use Git(Hub) to make changes on local (Wamp) and push changes to a live website (hosted on a hosting provider)?

I would like to use GitHub to track any changes I make to my website.

Steps done so far:

  1. I installed a fresh (latest) Silverstripe on an internet hosting and configured it
  2. Installed a theme (Watea) and made a few HTML and CSS changes, but realised I needed a way to track this changes.
  3. Website runs as expected on the live hosting. However, to be more diligent, I would like to make these changes locally (on my own computer) so I can test them, before pushing them back to Github and finally pushing changes to the live site.
  4. From the live website, I made a first commit to Git, configured Git remote and pushed the project into Github
  5. My .gitignore file reads as:
/silverstripe-cache/
/.env
/vendor/
/themes/simple/
/_resources/
/public/_resources/
  1. Using Github, I made a clone of the repository to my localserver. I am using WAMP where I have a few installed Silverstripe websites I use for training and learning.
  2. The repository is in the same folder as the other local websites I created for training
    wamp64/www/clonedrepository

The clone repository came without the Silverstripe core files, which is expected, so my question is, what’s the best way to replicate the live conditions (core files/modules/themes) without replacing anything on the cloned repository?

Is the best way to migrate (copy and paste) the folders present in the .gitignore file, from the live FTP to my locaserver cloned repository folder?

Many thanks if anyone can help
Caio

You might want to have a look at something like deployer (https://deployer.org/) or Deploy HQ (https://www.deployhq.com/)

These will allow you to do automated deployments based on your repository. You’d do all your development locally, only committing your own files and things like your composer.lock file to the repo. The deployment scripts will then pull from your repo (from whatever branch / commit you want), run an automated build and upload the changed files the the target. If you get set up right, you never actually need to access the hosting filesystem directly… since the deployment system manages it all for you (even things like roll-backs, etc.)

Hope that helps!

Hi.

Composer is very much the way to manage your product.

If you have a composer.lock file in your local copy, running composer install should get all the external dependencies (core files, add-ons, etc.)

You’ll manage your local installation using composer… so if (for example) you want to add a new module, you’d use the composer require command to add it to your project. You’d refresh the packages with composer update and so-forth.
When you run these commands, composer will update your composer.json and composer.lock files.

If you commit your composer.lock file to your repo, as part of the deployment process you’d automatically run something like composer install --no-dev - this would make sure you have the same versions / combination of packages in your deployment target.

I hope that makes sense!

1 Like

Hi Tim,

Thank you for your answer. The tools you provided indeed help in terms of giving automated options, I have already signed up for one of them and it looks a more smooth deployment process, thank you.

However, I am still struggling on how to transform my cloned repository locally in a website (i.e. add the Silverstripe core files back, framework, etc).

I have read on other forums to run ‘composer install’ or ‘composer update’, but I am having no lucky with those, so I am still digging the tutorials and forums.

On this old thread, they suggest to run composer install, but that’s 4 years old. Is it still the case for 2020 to run composer install?:

Many thanks
Caio