# Getting git submodules working

**URL:** <https://forum.getkirby.com/t/getting-git-submodules-working/1282>\
**Category:** Questions\
**Tags:** v2\
**Created:** [June 6, 2015, 6:05pm UTC](https://forum.getkirby.com/t/getting-git-submodules-working/1282 "2015-06-06T18:05:52Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![gtc](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gtc/32/119_2.png) [@gtc](https://forum.getkirby.com/u/gtc)\
**Post date:** [June 6, 2015, 6:05pm UTC](https://forum.getkirby.com/t/getting-git-submodules-working/1282/1 "2015-06-06T18:05:52Z")

</div>

I have a Kirby site I’ve been working on for some time. It’s tracked in a git repo (which I also use to deploy to my web server). I’ve been unable to get git submodules working for updating the `/kirby` and `/panel` directories.

I understand that this is one way to initialize those directories as submodules:

```
git submodule add https://github.com/getkirby/kirby.git
git submodule add https://github.com/getkirby/panel.git
git submodule update --init --recursive 

```

Will that work to add them as submodule directories? Do I need to

```
rm -rf ./kibry ./panel 

```

before issuing those commands?

Thanks!

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [June 6, 2015, 6:26pm UTC](https://forum.getkirby.com/t/getting-git-submodules-working/1282/2 "2015-06-06T18:26:34Z")

</div>

If you started with a copy of the `starterkit` repo, you can simply run `git submodule update --init --recursive`, as the submodules are already registered in that repository.  
What exactly does not work and which error message is generated by Git?

---

<div class="post-metadata">

**Author:** ![gtc](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gtc/32/119_2.png) [@gtc](https://forum.getkirby.com/u/gtc)\
**Post date:** [June 6, 2015, 6:29pm UTC](https://forum.getkirby.com/t/getting-git-submodules-working/1282/3 "2015-06-06T18:29:16Z")

</div>

I did not start with the `starterkit` repo. I’ve been updating manually by downloading the Kirby zip file and copying the `kirby` and `panel` directories into my project repo.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [June 6, 2015, 6:45pm UTC](https://forum.getkirby.com/t/getting-git-submodules-working/1282/4 "2015-06-06T18:45:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [June 6, 2015, 6:46pm UTC](https://forum.getkirby.com/t/getting-git-submodules-working/1282/5 "2015-06-06T18:46:13Z")

</div>

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. 😉

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [June 6, 2015, 6:48pm UTC](https://forum.getkirby.com/t/getting-git-submodules-working/1282/6 "2015-06-06T18:48:38Z")

</div>

> [@texnixe](#):
>
> As an alternative, you can edit your git config file and add the .gitmodules file manually.

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

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [June 6, 2015, 6:51pm UTC](https://forum.getkirby.com/t/getting-git-submodules-working/1282/7 "2015-06-06T18:51:15Z")

</div>

@lukasbestle Of course it makes more sense 😜

---

<div class="post-metadata">

**Author:** ![gtc](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gtc/32/119_2.png) [@gtc](https://forum.getkirby.com/u/gtc)\
**Post date:** [June 7, 2015, 1:09am UTC](https://forum.getkirby.com/t/getting-git-submodules-working/1282/8 "2015-06-07T01:09:26Z")

</div>

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.,

> <https://stackoverflow.com/questions/8372625/git-how-to-push-submodule-to-a-remote-repository>

I’m using the deployment method mentioned here:

> **[How To Set Up Automatic Deployment with Git with a VPS | DigitalOcean](https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps)**
>
> This article will teach you how to use Git when you want to deploy your application. While there are many ways to use Git to deploy our application, we'll focus on the one that is most straightforward.

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

---

<div class="post-metadata">

**Author:** ![SQBiz](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/sqbiz/32/5014_2.png) [@SQBiz](https://forum.getkirby.com/u/SQBiz)\
**Post date:** [June 7, 2015, 1:30am UTC](https://forum.getkirby.com/t/getting-git-submodules-working/1282/9 "2015-06-07T01:30:18Z")

</div>

@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](http://forum.getkirby.com/t/deploying-via-git/168)

---

<div class="post-metadata">

**Author:** ![gtc](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gtc/32/119_2.png) [@gtc](https://forum.getkirby.com/u/gtc)\
**Post date:** [June 7, 2015, 1:33am UTC](https://forum.getkirby.com/t/getting-git-submodules-working/1282/10 "2015-06-07T01:33:14Z")

</div>

(See edited post above. Thanks!)

---

<div class="post-metadata">

**Author:** ![gtc](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gtc/32/119_2.png) [@gtc](https://forum.getkirby.com/u/gtc)\
**Post date:** [June 7, 2015, 3:37am UTC](https://forum.getkirby.com/t/getting-git-submodules-working/1282/11 "2015-06-07T03:37:24Z")

</div>

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.

[http://aaronadams.ca/post/37345904654/git-push-with-submodules](http://aaronadams.ca/post/37345904654/git-push-with-submodules)

---

<div class="post-metadata">

**Author:** ![gtc](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gtc/32/119_2.png) [@gtc](https://forum.getkirby.com/u/gtc)\
**Post date:** [June 26, 2015, 9:36pm UTC](https://forum.getkirby.com/t/getting-git-submodules-working/1282/12 "2015-06-26T21:36:25Z")

</div>

[bump] Any ideas? Thanks!

---

<div class="post-metadata">

**Author:** ![SQBiz](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/sqbiz/32/5014_2.png) [@SQBiz](https://forum.getkirby.com/u/SQBiz)\
**Post date:** [June 27, 2015, 11:17pm UTC](https://forum.getkirby.com/t/getting-git-submodules-working/1282/13 "2015-06-27T23:17:39Z")

</div>

according to [this issue](https://github.com/LeanMeanFightingMachine/dploy/issues/48) on the github page for dploy, version 2 should be released soon and supports submodules.

---

<div class="post-metadata">

**Author:** ![gtc](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gtc/32/119_2.png) [@gtc](https://forum.getkirby.com/u/gtc)\
**Post date:** [June 28, 2015, 12:04am UTC](https://forum.getkirby.com/t/getting-git-submodules-working/1282/14 "2015-06-28T00:04:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tobiasweh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/tobiasweh/32/13376_2.png) [@tobiasweh](https://forum.getkirby.com/u/tobiasweh)\
**Post date:** [November 9, 2015, 12:13pm UTC](https://forum.getkirby.com/t/getting-git-submodules-working/1282/15 "2015-11-09T12:13:39Z")

</div>

Hi,

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 …

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [November 9, 2015, 1:15pm UTC](https://forum.getkirby.com/t/getting-git-submodules-working/1282/16 "2015-11-09T13:15:13Z")

</div>

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

```auto
git submodule add git@github.com:getkirby/panel.git

```

And the same for the core, of course.

---

<div class="post-metadata">

**Author:** ![tobiasweh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/tobiasweh/32/13376_2.png) [@tobiasweh](https://forum.getkirby.com/u/tobiasweh)\
**Post date:** [November 9, 2015, 1:31pm UTC](https://forum.getkirby.com/t/getting-git-submodules-working/1282/17 "2015-11-09T13:31:02Z")

</div>

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

```nohighlight
'panel' already exists in the index

```

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [November 9, 2015, 3:49pm UTC](https://forum.getkirby.com/t/getting-git-submodules-working/1282/18 "2015-11-09T15:49:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tobiasweh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/tobiasweh/32/13376_2.png) [@tobiasweh](https://forum.getkirby.com/u/tobiasweh)\
**Post date:** [November 9, 2015, 4:02pm UTC](https://forum.getkirby.com/t/getting-git-submodules-working/1282/19 "2015-11-09T16:02:00Z")

</div>

As far as I can tell no …

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

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [November 9, 2015, 4:04pm UTC](https://forum.getkirby.com/t/getting-git-submodules-working/1282/20 "2015-11-09T16:04:16Z")

</div>

You should be able to use the following:

```bash
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"

```

[Next page](https://forum.getkirby.com/t/getting-git-submodules-working/1282.md?page=2)
