# Git-commit-and-push-content

**URL:** <https://forum.getkirby.com/t/git-commit-and-push-content/2087>\
**Category:** Plugins\
**Created:** [September 24, 2015, 8:02am UTC](https://forum.getkirby.com/t/git-commit-and-push-content/2087 "2015-09-24T08:02:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pascalmh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/pascalmh/32/3612_2.png) [@Pascalmh](https://forum.getkirby.com/u/Pascalmh)\
**Post date:** [September 24, 2015, 8:02am UTC](https://forum.getkirby.com/t/git-commit-and-push-content/2087/1 "2015-09-24T08:02:37Z")

</div>

Hey,

I made a Plugin to version control the content folder using git. Using the [kirby panel hooks](http://getkirby.com/docs/panel/hooks) everything that can be hooked into will be staged, committed and pushed to its own git repository.

> **[blankogmbh/kirby-git-commit-and-push-content](https://github.com/blankogmbh/kirby-git-commit-and-push-content)**
>
> kirby-git-commit-and-push-content - Commit and Push changes made via the Panel

The git history will look like this:

```
sort(page): team/max-mustermann by kirby-panel-username 136b20af
upload(file): team/max-mustermann/max-mustermann.jpg by kirby-panel-username ede54f13
update(page): team/max-mustermann by kirby-panel-username d79daee5
create(page): team/max-mustermann by kirby-panel-username 853992b3

```

Let me know what you think, contributions are more than welcome!

**Going further:**  
As the commit messages are written as they are you can use [conventional-changelog](https://github.com/ajoslin/conventional-changelog) ([grunt version](https://github.com/btford/grunt-conventional-changelog/)) to automatically generate a [CHANGELOG.md](http://CHANGELOG.md).

---

<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:** [September 24, 2015, 8:11am UTC](https://forum.getkirby.com/t/git-commit-and-push-content/2087/2 "2015-09-24T08:11:36Z")

</div>

Looking forward to testing this 😀 Been thinking of creating such a plugin myself for a while …

---

<div class="post-metadata">

**Author:** ![rhawbert](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/rhawbert/32/586_2.png) [@rhawbert](https://forum.getkirby.com/u/rhawbert)\
**Post date:** [September 24, 2015, 2:37pm UTC](https://forum.getkirby.com/t/git-commit-and-push-content/2087/3 "2015-09-24T14:37:05Z")

</div>

I’m also looking forward to test this… since am still not pleased with my current deploy strategy. This thread from a while ago also didn’t brought much light to the issue:

[http://forum.getkirby.com/t/how-to-best-organize-files-folders-repos-the-deploy-strategy/489](http://forum.getkirby.com/t/how-to-best-organize-files-folders-repos-the-deploy-strategy/489)

---

<div class="post-metadata">

**Author:** ![jereze](https://avatars.discourse-cdn.com/v4/letter/j/e36b37/32.png) [@jereze](https://forum.getkirby.com/u/jereze)\
**Post date:** [October 6, 2015, 11:06am UTC](https://forum.getkirby.com/t/git-commit-and-push-content/2087/4 "2015-10-06T11:06:50Z")

</div>

Great! Thanks, I will give it a try.

---

<div class="post-metadata">

**Author:** ![vladox](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/vladox/32/1593_2.png) [@vladox](https://forum.getkirby.com/u/vladox)\
**Post date:** [January 25, 2016, 11:16pm UTC](https://forum.getkirby.com/t/git-commit-and-push-content/2087/5 "2016-01-25T23:16:55Z")

</div>

Hi  
Thanks for your plugin!  
I followed the instructions and I don’t seem to get it to work…  
It seems it’s a problem when $repo = Git::open(’…/content’); is called since it never comes back.  
I see some Exceptions can be thrown in the code but I don’t know exactly how do you they are displayed in the panel even when debug is set to true. They seem to be suppressed somehow.  
Do you have some tip on how to debug your plugin?  
Any hint is appreciated 🙂  
Best regards  
Vlad

---

<div class="post-metadata">

**Author:** ![Pascalmh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/pascalmh/32/3612_2.png) [@Pascalmh](https://forum.getkirby.com/u/Pascalmh)\
**Post date:** [January 26, 2016, 8:25am UTC](https://forum.getkirby.com/t/git-commit-and-push-content/2087/6 "2016-01-26T08:25:22Z")

</div>

You can open the Dev Tools in your Browser and select the Network-Panel. When you hit “Save” in the Kirby Panel there will be a new Request if you click on it and check the Response there will be the error message you are looking for.

---

<div class="post-metadata">

**Author:** ![vladox](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/vladox/32/1593_2.png) [@vladox](https://forum.getkirby.com/u/vladox)\
**Post date:** [January 26, 2016, 9:39am UTC](https://forum.getkirby.com/t/git-commit-and-push-content/2087/7 "2016-01-26T09:39:29Z")

</div>

Hi Thanks for the response. I’ve tried your suggestion but I don’t see any errors popping up there only some html being returned with a 200 status. So the exceptions are not being returned from git.php. I think you are talking about the echo messages in your code directly.  
Here more background on what’s happening:

> <https://github.com/kbjr/Git.php/issues/41>

---

<div class="post-metadata">

**Author:** ![vladox](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/vladox/32/1593_2.png) [@vladox](https://forum.getkirby.com/u/vladox)\
**Post date:** [January 26, 2016, 9:23am UTC](https://forum.getkirby.com/t/git-commit-and-push-content/2087/8 "2016-01-26T09:23:04Z")

</div>

Hi Lukas,

Thanks for the advice!  
We have tried to used the suggested plugin but encounter some difficulties with the commits:

[https://github.com/kbjr/Git.php/issues/41](https://github.com/kbjr/Git.php/issues/4)

Have you seen something like that?  
Also the hook triggered doesn’t seems to be correct one, sort instead of update.

---

<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:** [January 26, 2016, 11:09am UTC](https://forum.getkirby.com/t/git-commit-and-push-content/2087/9 "2016-01-26T11:09:38Z")

</div>

One reason could be that your webserver and therefore PHP runs as a different user than on your shell. You should be able to fix this by running the commands directly in the repository and leaving out the `--global` option so that the values are saved to the content repository.

---

<div class="post-metadata">

**Author:** ![vladox](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/vladox/32/1593_2.png) [@vladox](https://forum.getkirby.com/u/vladox)\
**Post date:** [January 28, 2016, 11:41am UTC](https://forum.getkirby.com/t/git-commit-and-push-content/2087/10 "2016-01-28T11:41:59Z")

</div>

Thanks for the suggestions, but I’m running apache locally under my login account. The same that Terminal is using. And the content repository as already the information.  
Very strange indeed.

---

<div class="post-metadata">

**Author:** ![rhawbert](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/rhawbert/32/586_2.png) [@rhawbert](https://forum.getkirby.com/u/rhawbert)\
**Post date:** [February 2, 2016, 10:25pm UTC](https://forum.getkirby.com/t/git-commit-and-push-content/2087/11 "2016-02-02T22:25:24Z")

</div>

Does the **panel.file.move** hook exists?  
If so… It’s [not in the docs](http://getkirby.com/docs/panel/developers/hooks).

Anyway, I can’t get this work… and it doesn’t throw any errors… sigh.

I’ve thought that changing line 32 of **helper.php** would do it… nope:

```php
$repo = Git::open('..'. DS .'content');

```

Any insights on how to debug this?

---

<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:** [February 3, 2016, 12:38pm UTC](https://forum.getkirby.com/t/git-commit-and-push-content/2087/12 "2016-02-03T12:38:39Z")

</div>

> [@rhawbert](#):
>
> Does the panel.file.move hook exists?

That hook is named `panel.file.rename`.

---

<div class="post-metadata">

**Author:** ![rhawbert](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/rhawbert/32/586_2.png) [@rhawbert](https://forum.getkirby.com/u/rhawbert)\
**Post date:** [March 16, 2016, 2:25pm UTC](https://forum.getkirby.com/t/git-commit-and-push-content/2087/13 "2016-03-16T14:25:40Z")

</div>

Does it work when using a different repo for the _content_ folder?

In my tests nothing happens…

---

<div class="post-metadata">

**Author:** ![Jasper2-0](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jasper2-0/32/2010_2.png) [@Jasper2-0](https://forum.getkirby.com/u/Jasper2-0)\
**Post date:** [April 16, 2016, 6:02pm UTC](https://forum.getkirby.com/t/git-commit-and-push-content/2087/14 "2016-04-16T18:02:40Z")

</div>

I’m having some trouble getting this set up; I managed to follow along so far:

- Separating out content and the rest into two repositories
- Installing the plugin (it’s in site/plugins/git-commit-and-push-content/)
- I added this option to my config.php: `c::set('gcapc-commit',true);`

Did I miss any essential steps? Anything not in the readme I should be aware of?  
Git is working on my server, I can manually commit, push and pull my content / site from and to github…

---

<div class="post-metadata">

**Author:** ![Pascalmh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/pascalmh/32/3612_2.png) [@Pascalmh](https://forum.getkirby.com/u/Pascalmh)\
**Post date:** [April 19, 2016, 10:06am UTC](https://forum.getkirby.com/t/git-commit-and-push-content/2087/15 "2016-04-19T10:06:13Z")

</div>

Make sure you have a `Git.php`-Folder inside the `git-commit-and-push-content` folder that isn’t empty - (which is a submobule of this Plugin that can be found here: [https://github.com/kbjr/Git.php](https://github.com/kbjr/Git.php)).

You might want to enable the Push and Pull option aswell, so set `gcapc-push` and `gcapc-pull` to true.

---

<div class="post-metadata">

**Author:** ![Jasper2-0](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jasper2-0/32/2010_2.png) [@Jasper2-0](https://forum.getkirby.com/u/Jasper2-0)\
**Post date:** [April 20, 2016, 9:52pm UTC](https://forum.getkirby.com/t/git-commit-and-push-content/2087/16 "2016-04-20T21:52:39Z")

</div>

Thanks Pascal, both are installed and present on the server. I’ve added push and pull options. However, I haven’t been able to get it to work, manually committing and pushing the changes in the content folder to github via SSH does work. You’ve mentioned in previous posts that errors should show up in the Network pannel when using Dev Tools. When I save using panel, I get a XHR with status code 200, and some json is returned, I don’t see any errors coming from the plugin, which makes this a bit hard to debug. Do you have any suggestions as to what I might try?

Thanks again for helping out!

---

<div class="post-metadata">

**Author:** ![Pascalmh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/pascalmh/32/3612_2.png) [@Pascalmh](https://forum.getkirby.com/u/Pascalmh)\
**Post date:** [April 21, 2016, 3:40pm UTC](https://forum.getkirby.com/t/git-commit-and-push-content/2087/17 "2016-04-21T15:40:51Z")

</div>

I just pushed a new Version (1.1.1) where some stuff got refactored, can you try it again with the newsest version? And could you give me the Git Commands you are using when you commit and push manually on the server?

---

<div class="post-metadata">

**Author:** ![Jasper2-0](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jasper2-0/32/2010_2.png) [@Jasper2-0](https://forum.getkirby.com/u/Jasper2-0)\
**Post date:** [April 22, 2016, 11:22pm UTC](https://forum.getkirby.com/t/git-commit-and-push-content/2087/18 "2016-04-22T23:22:43Z")

</div>

Hi Pascal, I’m afraid I’m still running into problems, I’m hoping you can spare some time to have a look. I’ve tried to simplify by just working with a vanilla kirby installation.

I’ve set up some public repositories to allow you to have a look at what might be wrong. Both can be found here:

> **[Jasper2-0/gcapc-test](https://github.com/Jasper2-0/gcapc-test)**
>
> Contribute to gcapc-test development by creating an account on GitHub.

  

> **[Jasper2-0/gcapc-test-content](https://github.com/Jasper2-0/gcapc-test-content)**
>
> Contribute to gcapc-test-content development by creating an account on GitHub.

gcapc-test contains a vanilla kirby installation (2.2.3), and I followed your readme to my best abilities. the content for this kirby installation is in gcapc-test-content. As far as I can determine your 1.1.1 update and Git.php are installed succesfully from github.

Currently when running this installation with php on the commandline, (OSX 10.11.4) it returns the following error:  
/ - parse error, expecting `’)’’ in /Users/username/Development/02\_Github\_Public/gcapc-test/site/plugins/git-commit-and-push-content/helpers.php on line 14

I’m a bit stumped as for what might be wrong, because that line seems fine to me…

---

<div class="post-metadata">

**Author:** ![Jasper2-0](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jasper2-0/32/2010_2.png) [@Jasper2-0](https://forum.getkirby.com/u/Jasper2-0)\
**Post date:** [April 23, 2016, 7:38am UTC](https://forum.getkirby.com/t/git-commit-and-push-content/2087/19 "2016-04-23T07:38:24Z")

</div>

Ok, I moved some code around in helpers.php and now I have commits appearing on github.

I changed:

```
public function __construct($repoPath =__DIR__. "/../../../content")
    {
        $this->repoPath = $repoPath;
        $this->branch = c::get('gcapc-branch', 'master');
    }

public function __construct()
    {
        $this->repoPath = __DIR__. "/../../../content";
        $this->branch = c::get('gcapc-branch', 'master');
    }

```

And things are starting to work now, the only thing I have to look further at is why page content updates are appearing as sorts in the repository…

^ fixed in 2.3.0 beta, so it works like a charm…

---

<div class="post-metadata">

**Author:** ![mrflix](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mrflix/32/14443_2.png) [@mrflix](https://forum.getkirby.com/u/mrflix)\
**Post date:** [May 13, 2016, 9:48am UTC](https://forum.getkirby.com/t/git-commit-and-push-content/2087/20 "2016-05-13T09:48:43Z")

</div>

It might be obviouse for some but the plugin doesn’t work when git is not correctly configured for the user running the php process. Unfortunately the plugin fails silently and doesn’t catch that error.

[Next page](https://forum.getkirby.com/t/git-commit-and-push-content/2087.md?page=2)
