Skip to content

Instantly share code, notes, and snippets.

@dan2k3k4
Created April 29, 2014 14:17
Show Gist options
  • Save dan2k3k4/11401734 to your computer and use it in GitHub Desktop.
Save dan2k3k4/11401734 to your computer and use it in GitHub Desktop.
Post Commit hook to commit an empty commit with the message and title of a repo to another repo (i.e. can be used to log all your git commits from multiple repos into one central repo location). For fun.
#!/usr/bin/php
<?php
/**
* .git/hooks/post-commit
*
* This post-commit hook is just for fun.
* Set up your central repository then set the post-commit hook into your other repositories that you want to log
*
* @author dan2k3k4 http://github.com/dan2k3k4
* @since April 29 2014
*
*/
$centralRepo = "__DEFINE_YOUR_REPO_HERE";
/**
* Get the git repo name and message
*/
$gitRepo = '';
$gitMessage = '';
exec('git rev-parse --show-toplevel', $gitRepo);
$gitRepo = basename($gitRepo[0]);
exec('git log -1 HEAD --pretty=format:%s', $gitMessage);
$gitMessage = $gitMessage[0];
exec('git --git-dir="' . $centralRepo . '.git" --work-tree="' . $centralRepo . '" commit --allow-empty -m "' . $gitRepo . ' => ' . $gitMessage . '"');
@dan2k3k4
Copy link
Author

Think a D3js enabled web app that gets the git-log output from this "git log central repository" would be nice to teach myself about node-webkit and D3js if I get time...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment