How to display git commits on DokuWiki page

Lets display git commits using DokuWiki on your own project workspace or personal wiki.

Create system user that can access git repositories and wiki pages.

$ sudo useradd -s /usr/sbin/nologin -G "git,www-data" -r wiki-git-bridge

Create external namespace for DokuWiki installed in /opt/wiki/ directory.

$ sudo mkdir /opt/wiki/data/pages/external

Change owner and group from root to www-data.

$ sudo chown www-data:www-data /opt/wiki/data/pages/external

Add write access for assigned group.

$ sudo chmod g+w /opt/wiki/data/pages/external

Create /opt/sbin/ shell script to generate commits for /opt/repositories/blog.git git repository and store it using /opt/wiki/data/pages/external/git_blog_log.txt wiki page file.

# display recent repository changes using dokuwiki syntax

# number of recent changes

# git repository

# output directory and filename

# header title
header_title="Recent changes"

echo "==== ${header_title} ====" | tee $output >/dev/null
git --git-dir="${git_repository}" log --max-count="${n_changes}" --date=short --pretty=format:"  * **%h** **%ad** \\\\  //%s//" | tee -a $output >/dev/null

Verify that created shell script is running without any problems.

$ sudo -u wiki-git-bridge  /opt/sbin/

Create cron job to schedule script execution.

$ cat << EOF | sudo tee /etc/cron.d/wiki_blog_log

# Generate recent repository changes page
15 */3 * * * wiki-git-bridge [ -x /opt/sbin/ ] && /opt/sbin/


Use include plugin to embed generated page.

Milosz Galazka's Picture

About Milosz Galazka

Milosz is a Linux Foundation Certified Engineer working for a successful Polish company as a system administrator and a long time supporter of Free Software Foundation and Debian operating system.

Gdansk, Poland