Created
April 29, 2014 14:17
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 . '"'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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...