Mitchell McKenna - tagged with git http://mitchmckenna.com/feed en-us http://blogs.law.harvard.edu/tech/rss LifePress mitchellmckenna@gmail.com Git Pre-commit Hook to Auto Run PHPUnit http://mitchmckenna.com/post/15960/auto-run-phpunit-git-pre-commit-hook

Never push up broken tests again. Using a pre-commit hook for git, when you type in git commit git will automatically run your unit tests to make sure nothing is broken with your recent changes.

Create a file called pre-commit in your project root at ./.git/hooks/ and put the following code inside it:

#!/usr/bin/php
<?php
printf("%sGit pre-commit hook %1\$s", PHP_EOL);
$projectName = basename(getcwd());
exec('vendor/bin/phpunit', $output, $returnCode);
if ($returnCode !== 0) {
    $minimalTestSummary = array_pop($output);
    printf("Test suite for %s failed: ", $projectName);
    printf("( %s ) %s%2\$s", $minimalTestSummary, PHP_EOL);
    return false;
}
printf("All tests for %s passed.%s%2\$s", $projectName, PHP_EOL);
return true;


The above is based on this gist but updated to use the copy of phpunit from your project's composer.

]]>
Fri, 20 Nov 2015 10:53:52 -0500 http://mitchmckenna.com/post/15960/auto-run-phpunit-git-pre-commit-hook/auto-run-phpunit-git-pre-commit-hook
Gitifier: Git commit notifier for Mac http://mitchmckenna.com/post/15312/gitifier-git-commit-notifier-for-mac

Got a git repo you want a notification for when others commit to? Maybe it's your work repo (doesn't have to be github, can be any git repo). This app fits the bill. On the other hand if your looking for something to monitor github pull requests and comments, checkout Trailer.app.

]]>
Thu, 02 Apr 2015 04:41:00 -0400 http://mitchmckenna.com/post/15312/gitifier-git-commit-notifier-for-mac/gitifier-git-commit-notifier-for-mac
Git: How to Squash Commits http://mitchmckenna.com/post/15265/git-squash-commits

Let's say you have several commits you'd like to combine into a single commit. Or an open source project you made a pull request to asked you to squash all your commits into one. You can squash them and they don't even have to have happened one after another.

git rebase -i HEAD~n

Where n is the number of the commits into the commit history to show to pick from.

It will open vim and look something like this

Now just change the word "pick" in front of the commit you want to squash to "squash" or "s". You can re-order commits if you want. Ones you change to "s" will be merged into the commit above it.

Then save and quit like you normally do, and it'll take you to a second page in vim where you can construct the merged commit message from the previous 2 commit messages. Save and exit.

Now just push up the changes: git push --force origin [branch-name]

Done!

For a more detailed explanation see the git manual: http://git-scm.com/docs/git-rebase#_interactive_mode

]]>
Thu, 19 Mar 2015 19:18:38 -0400 http://mitchmckenna.com/post/15265/git-squash-commits/git-squash-commits
Git 2.3 feature - Push to Deploy http://mitchmckenna.com/post/15153/git-23-feature-push-to-deploy

One of the new features built into Git 2.3 is ability to deploy when you push. If you've got a simple project, this might be all you need instead of a deployment script/package.

]]>
Fri, 06 Feb 2015 03:46:00 -0500 http://mitchmckenna.com/post/15153/git-23-feature-push-to-deploy/git-23-feature-push-to-deploy
Used 'git add -p' for the first time today, super useful http://mitchmckenna.com/post/12123/mitchellmckenna-used-git-add-p-for-the-first-time-today-super-useful-httptcoxfmhge7p-git

Used 'git add -p' for the first time today, super useful http://t.co/xfmHge7P #git

]]>
Tue, 27 Nov 2012 14:09:00 -0500 http://mitchmckenna.com/post/12123/mitchellmckenna-used-git-add-p-for-the-first-time-today-super-useful-httptcoxfmhge7p-git/mitchellmckenna-used-git-add-p-for-the-first-time-today-super-useful-httptcoxfmhge7p-git
Bitbucket posting an article supporting GIT over Mercurial - you wouldn't have seen that 6 months http://mitchmckenna.com/post/10920/mitchellmckenna-bitbucket-posting-an-article-supporting-git-over-mercurial-you-wouldnt-have-seen-that-6-months-ago-httptcobwgkj9tz-via-bailylo

Bitbucket posting an article supporting #GIT over #Mercurial - you wouldn't have seen that 6 months ago http://t.co/BWgkJ9tz (via @bailylo)

]]>
Wed, 14 Mar 2012 21:16:00 -0400 http://mitchmckenna.com/post/10920/mitchellmckenna-bitbucket-posting-an-article-supporting-git-over-mercurial-you-wouldnt-have-seen-that-6-months-ago-httptcobwgkj9tz-via-bailylo/mitchellmckenna-bitbucket-posting-an-article-supporting-git-over-mercurial-you-wouldnt-have-seen-that-6-months-ago-httptcobwgkj9tz-via-bailylo
Github's @chacon talks gitflow and how @github's workflow works http://mitchmckenna.com/post/10031/mitchellmckenna-githubs-chacon-talks-gitflow-and-how-githubs-workflow-works-httptcoceyvzz6-git-via-jonursenbach

Github's @chacon talks #gitflow and how @github's workflow works http://t.co/ceYVzz6 #git (via @jonursenbach)

]]>
Wed, 31 Aug 2011 15:20:00 -0400 http://mitchmckenna.com/post/10031/mitchellmckenna-githubs-chacon-talks-gitflow-and-how-githubs-workflow-works-httptcoceyvzz6-git-via-jonursenbach/mitchellmckenna-githubs-chacon-talks-gitflow-and-how-githubs-workflow-works-httptcoceyvzz6-git-via-jonursenbach
Sparks with Git in CodeIgniter [Video Tutorial] http://mitchmckenna.com/post/9526/sparks-with-git-in-codeigniter-video-tutorial

"This is a quick video outlining how you can create Sparks in CodeIgniter using Git. I take my Template library as an example and upgrade it from v1.7.0 to v1.8.0, finishing in a bit of a ramble about how Sparks can help fix some of the problems in the CodeIgniter community. Sparks are pretty damn awesome, check the video out and have a play with them when you're done."

]]>
Sun, 08 May 2011 01:28:00 -0400 http://mitchmckenna.com/post/9526/sparks-with-git-in-codeigniter-video-tutorial/sparks-with-git-in-codeigniter-video-tutorial
Hg Init: a Mercurial tutorial by Joel Spolsky http://mitchmckenna.com/post/6456/hg-init-a-mercurial-tutorial-by-joel-spolsky

Mercurial is a modern, open source, distributed version control system, and a compelling upgrade from older systems like Subversion. In this user-friendly, six-part tutorial, Joel Spolsky teaches you the key concepts.

]]>
Thu, 25 Feb 2010 22:01:00 -0500 http://mitchmckenna.com/post/6456/hg-init-a-mercurial-tutorial-by-joel-spolsky/hg-init-a-mercurial-tutorial-by-joel-spolsky
Why Git is Better Than X http://mitchmckenna.com/post/4082/why-git-is-better-than-x

"Why people are switching to Git from SubVersion, Perforce, and Bazaar. Outlines the many advantages to using GIT for version control"

]]>
Tue, 25 Aug 2009 00:22:00 -0400 http://mitchmckenna.com/post/4082/why-git-is-better-than-x/why-git-is-better-than-x