Search

Hi Guys,

I've been re-setting up my Symphony website under Git following Jonas' great guide, using submodules for extensions and the workspace etc.

I've also been looking into deploying via Git, using this very simple method.

My problem is that when I git push dev to push my files to the remote repository (which in turn sends my files to the webroot), it doesn't send the submodules (extensions etc).

I've also been reading Nils' guide on submodules and understand the concepts around this, but is there anyway to have the files from the submodules also sent to the remote repo witout having to set up a remote within each submodule?

Thanks,

Mark

You need to initialize the submodules in your remote repository:

git submodule update --init

Submodules are probably my biggest headache and favourite thing about Git…. :P

Hi tachyondecay,

I've tried this and get the following:

fatal: /usr/lib/git-core/git-submodule cannot be used without a working tree

I'm assuming this is because its a 'bare' repository called with git --bare init? My Git skills aren't so hot!

No worries. I only started using Git last summer, so I’m still figuring it out too. :)

Your deduction appears correct. Initializing submodules involves checking out files, which has no place in a bare repository.

It sounds like I have the same setup that you do: - Local repository for development/testing - Bare repository on remote server as a centralized “master” copy - Production repository on remote server that pulls from the bare repo for your live site.

So what I do is push to the bare repo from my computer, then I SSH into my server and cd into the directory containing the production repo. From there I run git pull to get the latest commits from the bare repo, and then I do git submodule update to make sure my submodules are initialized to the right commits.

If you have a script that automatically does this when you push to the bare repo, then you’ll need to modify it to tell the production repository to run git submodule update --init. I haven’t automated it because I don’t necessarily want to deploy new changes every time I push to the bare repo (sometimes I check them out in a staging copy on the remote server first, depending on how major they are).

So what I do is push to the bare repo from my computer, then I SSH into my server and cd into the directory containing the production repo. From there I run git pull to get the latest commits from the bare repo

Why not push to production repo to save a step?

Why not push to production repo to save a step?

Git doesn’t like pushing to checked out branches of non-bare repositories (because you are overwriting the working copy and any changes that might have been made there). There are ways to work around this, but I decided the above method was easier for me.

From there I run git pull to get the latest commits from the bare repo, and then I do git submodule update to make sure my submodules are initialized to the right commits.

I'd considered this but I didn't know if it was a bad thing to have the .git directory in the web directory?

At the moment I git push dev to my dev repo, which in turn sends all my files to my development webroot directory via a simple hook/post-receive shell script.

I've not got as far as considering production yet, I have the dev subdomain to test things work on my server (outside of WAMP/MAMP) and I'm considering manually moving all the files via SSH when I want to move to production.

I think the difference here is that I have 3 versions of the site to your 2, as in Local, Dev and Production whereas you use Local and Production with a central repo.

It sounds like it might just be worth me working locally with git and having a remote central repo, but when it comes to putting files 'online' on either the dev or live just do that via SFTP with Sublime or similar?

In the example you provided for the deploy, try changing the line

GIT_WORK_TREE=/var/www/www.example.org git checkout -f

to

GIT_WORK_TREE=/var/www/www.example.org git checkout -f && git submodule update --init --recursive

Hi John,

I tried that and I get remote: You need to run this command from the toplevel of the working tree.

I'm assuming this because its a --bare repo there is no working tree?

It looks like when working with submodules this deployment method isn't the way to go? I may just set up another repo in my dev web directory and pull from the remote repo when I need things moved to development?

Can't see much of a way around this with my limited knowledge.

Just replicating that block of code, and adding stuff, try

$ mkdir /var/www/www.example.org
$ cat > hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/var/www/www.example.org git checkout -f
DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd /var/www/www.example.org/ && git submodule update --init --recursive
cd $DIR
$ chmod +x hooks/post-receive

Give that a go. I haven't tested it...

I've tried that and I get

fatal:Not a git repository

Which makes sense, because if I'm translating your code correctly its going into the webroot and running git submodule update --init --recursive, the actual folder has no attachment to git, just the remote repo throws files at it after a push.

Its looking likely I'll just have to set up a second Git (Working tree) repo in the webroot to be able to get this working, and then move files over to live when needed.

I'll leave this for now as its relatively unimportant, but if I happen across a solution I'll let you know.

Thanks,

Mark

Yep, didn't think of that. I'd love to find a way to get that working too.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details