{"id":13527132,"url":"https://github.com/kimmobrunfeldt/git-hours","last_synced_at":"2025-05-16T00:03:51.098Z","repository":{"id":18249462,"uuid":"21402382","full_name":"kimmobrunfeldt/git-hours","owner":"kimmobrunfeldt","description":"Estimate time spent on a git repository","archived":false,"fork":false,"pushed_at":"2023-12-05T21:02:49.000Z","size":423,"stargazers_count":790,"open_issues_count":12,"forks_count":62,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-12T13:49:21.317Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kimmobrunfeldt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2014-07-01T21:02:20.000Z","updated_at":"2025-05-11T14:47:21.000Z","dependencies_parsed_at":"2024-01-13T22:46:59.360Z","dependency_job_id":"ca300d4c-0fb1-42e2-a3ad-27a06bbf8478","html_url":"https://github.com/kimmobrunfeldt/git-hours","commit_stats":{"total_commits":136,"total_committers":17,"mean_commits":8.0,"dds":0.3897058823529411,"last_synced_commit":"c589eea5174ee6439b68b4b437e443e7b6e4bf7b"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kimmobrunfeldt%2Fgit-hours","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kimmobrunfeldt%2Fgit-hours/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kimmobrunfeldt%2Fgit-hours/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kimmobrunfeldt%2Fgit-hours/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kimmobrunfeldt","download_url":"https://codeload.github.com/kimmobrunfeldt/git-hours/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254442854,"owners_count":22071878,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T06:01:41.768Z","updated_at":"2025-05-16T00:03:49.837Z","avatar_url":"https://github.com/kimmobrunfeldt.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"[![Status badge](https://github.com/kimmobrunfeldt/git-hours/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/kimmobrunfeldt/git-hours/actions?query=branch%3Amaster)\n\n# git-hours\n\nEstimate time spent on a git repository.\n\n**For example time spent on [Twitter's Bootstrap](https://github.com/twbs/bootstrap)**\n\n```javascript\n➜  bootstrap git:(master) git-hours\n{\n\n  ...\n\n  \"total\": {\n    \"hours\": 9959,\n    \"commits\": 11470\n  }\n}\n```\n\nFrom a person working 8 hours per day, it would take more than 3 years to build Bootstrap.\n\n*Please note that the information might not be accurate enough to be used in billing.*\n\n## Install\n\n    $ npm install -g git-hours\n\n**NOTE:** If for some reason `git-hours` won't work, try to `npm install -g nodegit`.\n\n`git-hours` depends on [nodegit](https://github.com/nodegit/nodegit).\nIt might be a bit tricky to install. If installing git-hours fails for some\nreason, probably it was because nodegit couldn't be installed.\nCheck [their documentation](https://github.com/nodegit/nodegit#getting-started) for troubleshooting.\n\n## How it works\n\nThe algorithm for estimating hours is quite simple. For each author in the commit history, do the following:\n\n\u003cbr\u003e\u003cbr\u003e\n\n![](docs/step0.png)\n\n*Go through all commits and compare the difference between\nthem in time.*\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n![](docs/step1.png)\n\n*If the difference is smaller or equal then a given threshold, group the commits\nto a same coding session.*\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n![](docs/step2.png)\n\n*If the difference is bigger than a given threshold, the coding session is finished.*\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n![](docs/step3.png)\n\n*To compensate the first commit whose work is unknown, we add extra hours to the coding session.*\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n![](docs/step4.png)\n\n*Continue until we have determined all coding sessions and sum the hours\nmade by individual authors.*\n\n\u003cbr\u003e\n\nThe algorithm in [~30 lines of code](https://github.com/kimmobrunfeldt/git-hours/blob/8aaeee237cb9d9028e7a2592a25ad8468b1f45e4/index.js#L114-L143).\n\n## Usage\n\nIn root of a git repository run:\n\n    $ git-hours\n\n**Note: repository is not detected if you are not in the root of repository!**\n\nHelp\n\n    Usage: git-hours [options]\n\n    Options:\n\n      -h, --help                                 output usage information\n      -V, --version                              output the version number\n      -d, --max-commit-diff [max-commit-diff]    maximum difference in minutes between commits counted to one session. Default: 120\n      -a, --first-commit-add [first-commit-add]  how many minutes first commit of session should add to total. Default: 120\n      -s, --since [since-certain-date]           Analyze data since certain date. [always|yesterday|tonight|lastweek|yyyy-mm-dd] Default: always'\n      -e, --email [emailOther=emailMain]         Group person by email address. Default: none\n      -u, --until [until-certain-date]           Analyze data until certain date. [always|yesterday|today|lastweek|thisweek|yyyy-mm-dd] Default: always\n      -m, --merge-request [false|true]           Include merge requests into calculation.  Default: true\n      -p, --path [git-repo]                      Git repository to analyze. Default: .\n      -b, --branch [branch-name]                 Analyze only data on the specified branch. Default: all branches\n\n    Examples:\n\n     - Estimate hours of project\n\n         $ git-hours\n\n     - Estimate hours in repository where developers commit more seldom: they might have 4h(240min) pause between commits\n\n         $ git-hours --max-commit-diff 240\n\n     - Estimate hours in repository where developer works 5 hours before first commit in day\n\n         $ git-hours --first-commit-add 300\n\n     - Estimate hours work in repository since yesterday\n\n       $ git-hours --since yesterday\n\n     - Estimate hours work in repository since 2015-01-31\n\n       $ git-hours --since 2015-01-31\n\n    - Estimate hours work in repository on the \"master\" branch\n\n       $ git-hours --branch master\n\n    For more details, visit https://github.com/kimmobrunfeldt/git-hours\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkimmobrunfeldt%2Fgit-hours","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkimmobrunfeldt%2Fgit-hours","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkimmobrunfeldt%2Fgit-hours/lists"}