Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Deletes all branches in a git repo of which the last commit is not authored by Morris
$branchesOutput = shell_exec('git branch | egrep -v "^\\*"');
$branches = explode("\n", $branchesOutput);
foreach ($branches as $branch) {
$branch = trim($branch);
if ($branch === '') {
$output = shell_exec("git show $branch | head -n 2 | grep 'Author:' | grep -v Morris -q && git branch -D $branch");
if (!empty($output)) {
echo $output;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment