How do you guys git?

Just wondering what the general preference is if you git init on the whole project or just the theme?

Typically with other CMS’s I would do the whole thing but with wordpress and Roots, just the theme makes more sense…kinda…but then plugins and such arent included so I’m a bit lost for how best to approach it tbh.

Typically my workflow with git would involve working locally on a development branch with the whole CMS (when it isnt roots / wordpress) then push to a staging site for review (SSH into staging site and git pull origin develop) then when its ready for live pretty much do the same thing but merge to master locally, run production / minification script in terminal, commit, push to live.

And also while doing the above, exporting database locally and then importing to live / development site.

I version control the whole project (usually Bedrock+Sage). All plugins are installed via Composer (wpackagist) from Bedrock’s root directory.

Things like Sage Directives, etc. are installed via Composer in Sage’s directory.

I was looking into Bedrock but unfortunately only found out about it too late and all projects I have started with Sage are only using sage…is it possible to migrate easily or would I essentially have to start again and re-build the sites?

The rebuild I imagine would be easy enough as I assume I would just be copy / pasting code into the new file structure but it would be time consuming…

It really shouldn’t be an issue at all.

You install Bedrock, configure your webserver to point to /web as the public path (e.g. /home/user/public_html/web), configure .env as you would wp-config.php, copy your existing theme, plugins, and uploads into web/app/X instead of wp-content/X – as far as getting it into the new file structure, you’re good to go.

Only remaining step would be converting wp-content/uploads to app/uploads within’ your database. This can easily be achieved using WP-CLI:

# Backup your database.
$ wp db export db.sql

# Run search-replace as a dry run initially.
$ wp search-replace wp-content/uploads app/uploads --dry-run

# Run search-replace.
$ wp search-replace wp-content/uploads app/uploads

After that you should be good to go.

1 Like

Additionally, not to lose all images SEO, I think it’s important to have 301 redirects for all wp-content related stuff to app. Sth like this in your .htaccess if you are using Apache.

<IfModule mod_rewrite.c> 
RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET\ /wp-content/
RewriteRule ^wp-content/(.*) /app/$1 [L,R=301]
</IfModule>

Not sure how to make this work with NGINX thoug :slight_smile:

I version control the whole project (Trellis+Bedrock) as 2 git repo.
All plugins are composified and installed via Composer from Bedrock’s root directory.

Be careful with redirections: You might need ^/wp-admin --> /wp/wp-admin as well
Scramming frog and google search console 404 logs are your friends.

Took a bit of tweaking but hot diggity it works!

Thanks!

Hey…so I have done this but git was initialised within the theme folder that I copied over before i moved it. Now when I run git init on the bedrock root folder it gives me an error “warning: adding embedded git repository”.

Normally I would find the .git folder and delete it to solve this problem but there is no .git folder and I’m thinking roots does some wierd magic to hide it away? How do I get rid of the repository inside the repository?

This topic was automatically closed after 42 days. New replies are no longer allowed.