Getting git submodules working

If you want to use the git submodule add command, you need to delete those two folders first, otherwise it won’t work.

As an alternative, you can edit your git config file and add the .gitmodules file manually.

In that case the commands you posted are exactly the right way to setup everything. Simply make sure to delete the Kirby and Panel directories first and run the three commands. After committing, you now basically have your own starterkit repo with your own code. :wink:

But given there is the git submodule add command, it makes much more sense to simply use that. :stuck_out_tongue:

@lukasbestle Of course it makes more sense :stuck_out_tongue_winking_eye:

OK, I this worked, but now when I push the repo to the server to deploy it uploads an empty kirby directory. Any ideas?

Edit: Looks like this might be a bit complicated. E.g.,

I’m using the deployment method mentioned here:

Maybe add the command to update kirby from post-receive?

@gtc, are you pushing to github or to your own server? Some deployment options like dandelion and git-ftp don’t work with submodules. see: Deploying via Git

(See edited post above. Thanks!)

So, I found this. I’ve not untangled the instructions or tried it yet, but it seems to allude to the possibility of making this work.

[bump] Any ideas? Thanks!

according to this issue on the github page for dploy, version 2 should be released soon and supports submodules.

Interesting. Thanks. Guess I could just scp the files up if I’m not using git directly.


as the new 2.1.2 is out I wonder if it is possible to add this as a submodule to an existing kirby project, i.e. there’s already a kriby folder but I want to sync it with the submodule now …

You can simply remove the existing folders, initialize a new Git repo (if not yet), and then add the submodules with

git submodule add

And the same for the core, of course.

That was what I tried, but it failed with this message

'panel' already exists in the index

That should only happen if the submodule already exist. Do you have a .gitmodules file in your repo?

As far as I can tell no …

BTW: I’m using Tower to manage my repos.

You should be able to use the following:

cd kirby
git checkout master
git pull
git submodule update --init --recursive
cd ..

cd panel
git checkout master
git pull
cd ..

git add kirby panel
git commit -m "Update Kirby"

Nope … I get

Tobis-Mac:kirby Tobi$ git pull
fatal: No remote repository specified.  Please, specify either a URL or a
remote name from which new revisions should be fetched.

My repo is only loan and not synced with GitHub or another server.

How did you install the project? did you clone it or make a repo out of a download?

I downloaded the starter kit (as ZIP), created a new empty repo in Tower and copied the files/folders form the starter kit into the repo. I guess this is not the best wys but I don’t know another :confounded: I really like the idea of using git but I’m an absolute beginner and don’t really know whats going on … :wink:

1 Like