Jump to content

How do you use GIT with PW?


benbyf
 Share

Recommended Posts

Feel like this is a perennial question and probably a duplicate...BUT I have a load of new PW sites and in the past I've git'ed on the template/ folders to gitlab, bitbucket, github or similar.

What are people doing to version control with PW as I would love to add more than the templates folder ideally (as I often make custom Modules) but wondered what people's strategies are?

Link to comment
Share on other sites

Might be easier to tell what I exclude which is:

  •  /site/assets
  •  /vendor
  • multiple things like "site/modules/ComposerModule" , example of any module that I manage through composer rather than git.
  • .env - I do this to be able to include config.php in version control.

On my todo is to try: https://github.com/uiii/processwire to also handle PW core as a composer dependency. 

 

  • Like 1
Link to comment
Share on other sites

I add to Git site and wire. On wire I have some Git patches that I may apply again after updating to a new version, and each wire version may solve or add bugs, so I add it to version control.

So .gitignore files exclude vendor directory and :

Quote

site/assets/cache/**/
site/assets/cache/*.maint
site/assets/sessions/sess_*
site/assets/logs/*.txt
site/templates/css/*.css
site/templates/css/*.map

I need some files in assets, so I exclude everything that is not needed and keep the rest.

I also add the database.sql to Git, a clean version ready to be deployed on a new site. Everytime I do changes in admin I export the DB.

  • Like 3
Link to comment
Share on other sites

I add Git in the root folder and can recommend GitKraken as app. 😀

I have a develop and a master branch and an origin remote. Our remote repositories are hosted on Bitbucket.

This is my current .gitignore file:

Spoiler
# OS
.DS_Store

# Visual Studio Code
/.vscode/
/*.code-workspace

# CodeKit
/config.codekit3
/.sass-cache

# Node
node_modules/

# Apache
/.htaccess

# Composer
/composer.lock
/vendor/

# ProcessWire
/site/config.php
/site/config-dev.php
/site/assets/

# SEO
/robots.txt
/googlec*.html
/BingSiteAuth.xml

Regards, Andreas

Edited by AndZyk
  • Like 3
Link to comment
Share on other sites

I use Git in the project root as well, and only put things in .gitignore I really don't want to have in that repo.

Best case scenario is that I have the full project, besides database dumps, in my repo.

# .gitignore
.ddev/
site/assets/backups/
site/assets/cache/
site/assets/logs/
site/assets/ProCache-*
site/assets/pwpc/
site/assets/sessions/
site/config-dev.php

Database dumps are a thing of its own. Managed projects are backed up quite often, long time projects with not that many updates will be backed up once every 3 months. From un-Managed projects I keep only the latest version I worked on - most of the time the release day or when something was updated.

  • Like 2
Link to comment
Share on other sites

On 11/27/2024 at 5:35 PM, benbyf said:

@AndZyk do you include /wire/ in your repo then and why?

Hello @benbyf,

yes I include the wire folder in my repo.

I am no Git expert but looked how .gitignore files for other CMS are recommended here in this popular collection on GitHub: https://github.com/github/gitignore
Most other CMS like WordPress, TYPO3, Joomla!, Kirby etc. recommend to add Git in the root folder and track the core folders.
For WordPress now it is recommended to optionally ignore the core folders, but at the time I was looking that wasn't the case.

Here are my pros and cons for adding Git in the root folder:

Pros

  • One repo for the complete website
  • You can clone the complete website with one command
  • Sometimes there are important files in the root, like f.e. Service Workers or Composer packages
  • You know which version of the CMS is used
  • You can use new functions of the CMS without keeping track of the CMS version somewhere else
  • If someone modifies or hacks your wire folder, you could see the differences

Cons

  • More commits
  • Larger repo

But ProcessWire gets a master version only once or twice a year, so the cons are for me not noticeable.

Of course as I said I am no Git expert and everybody is free to use Git how they want. 😀

Regards, Andreas

Edited by AndZyk
typo
  • Like 3
Link to comment
Share on other sites

  • 2 weeks later...
On 11/28/2024 at 2:30 PM, AndZyk said:

Hello @benbyf,

yes I include the wire folder in my repo.

I am no Git expert but looked how .gitignore files for other CMS are recommended here in this popular collection on GitHub: https://github.com/github/gitignore
Most other CMS like WordPress, TYPO3, Joomla!, Kirby etc. recommend to add Git in the root folder and track the core folders.
For WordPress now it is recommended to optionally ignore the core folders, but at the time I was looking that wasn't the case.

Here are my pros and cons for adding Git in the root folder:

Pros

  • One repo for the complete website
  • You can clone the complete website with one command
  • Sometimes there are important files in the root, like f.e. Service Workers or Composer packages
  • You know which version of the CMS is used
  • You can use new functions of the CMS without keeping track of the CMS version somewhere else
  • If someone modifies or hacks your wire folder, you could see the differences

Cons

  • More commits
  • Larger repo

But ProcessWire gets a master version only once or twice a year, so the cons are for me not noticeable.

Of course as I said I am no Git expert and everybody is free to use Git how they want. 😀

Regards, Andreas

Thank you so much.

  • Like 1
Link to comment
Share on other sites

On 11/27/2024 at 11:57 PM, wbmnfktr said:

Database dumps are a thing of its own. Managed projects are backed up quite often, long time projects with not that many updates will be backed up once every 3 months. From un-Managed projects I keep only the latest version I worked on - most of the time the release day or when something was updated.

How do you back up your database dumps? For regular backups of your dev environment?

I was thinking of something like a git hock and mysql command to dump the DB first into the root dir of the webproject and then make a commit aka push request.

Link to comment
Share on other sites

On my side I backup DB only manually (I run a mysqldump script), I never want an automatic dump because it may backup a database in a dirty state. My goal is to keep a clean version of DB that could be installed on a fresh server.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...