Skip to content
Switch branches/tags
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


PHP script to automatically submit time spend working on a software project based on git|hg commits to Rechnung+. ATM only Mercurial is supported. But I've only started the project today!


I need to enter time spent working on a software project into a time-tracking system. I've chosen Rechnung+ mainly because I've developed it ;-) and because it suit my needs. I often forget when did I start working today and have to guess working time. Now I think that there's a way to detect this information from the earliest modification time of any file in a project since previous commit. Having committed changes after working I know the ending time of the work. This gives us the duration of work. For accurate results I have to edit any file in the beginning of the work and not touch it until I commit. I also want to submit it to Rechnung+ automatically. This PHP script is doing it using Rechnung+ API. In the future it could be run as a post-commit hook. I understand this is not very precise but it's better than guessing.

Initial setup (done once)

  1. Download git-hg-rp files from github in ZIP or by git clone command. Extract ZIP.
  2. Create an account at Confirm your registration by the link in your mail.
  3. Set-up Rechnung+ project. Login to Rechnung+, create a client and a project. Make sure you enter your git|hg project name (folder name) into the "Tag" field in a project you create in Rechnung+ in square brackets. This way it will put the time into a correct project.
  4. Edit .hg/hgrc file in your(!) project (not in git-hg-rp) and enter your Rechnung+ credentials like this:
rp-login =
rp-pw = myPassword2012

Usage (do everytime after commit)

> php hg-git-rp.php

This will do everything described above including submitting the time to the project in Rechnung+.


Edit some files. Make sure you touch one file in the beginning of your work and don't change it until you commit. This will indicate the starting time.

Commit and run php git-hg-rp.php. Go back to Rechnung+ and see if you get a new record with the time you spent working listed. Make sure to explore other features of Rechnung+ like automatic invoicing and statistics.

Rechnung+ committed records

Example output

This is what I get when I execute the script:

$ php git-hg-rp.php
    [recordId] => 9:fb89284da8c9
    [startDate] => 20121020T040804+0200
    [endDate] => 20121020T040940+0200
    [note] => Final
    [tags] => Array
            [0] => git-hg-rp


    [Inserted] =>
    [Updated] => 1
    [Skipped] =>
    [MissingTag] =>

POST time: 0.406

Similar solutions

I want to share the information I've got when researching for similar projects. I've started by searching for "git time-tracking". When analyzing the result I found the following.

So there's no other script which does what I want. Poke me if you like it as it gives me more motivation to continue working on it.

Feedback is welcome. Enjoy.


PHP script to automatically submit working time spend before last commit to Rechnung+



No releases published


No packages published