<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Linux and Virtualization &#187; Project</title>
	<atom:link href="http://fclose.com/b/linux/topic/project/feed/" rel="self" type="application/rss+xml" />
	<link>http://fclose.com/b/linux</link>
	<description>Clear solutions, tutorials and tips on Linux and virtualization from the author&#039;s experience with clusters.</description>
	<lastBuildDate>Thu, 09 Feb 2012 14:49:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Setting Up Git Commit Email Notifications</title>
		<link>http://fclose.com/b/linux/1473/setting-up-git-commit-email-notification/</link>
		<comments>http://fclose.com/b/linux/1473/setting-up-git-commit-email-notification/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 06:21:36 +0000</pubDate>
		<dc:creator>Zhiqiang Ma</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Project]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[Server config]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://zhiqiangma.info/?p=1473</guid>
		<description><![CDATA[A method to send email notification to a list email addresses by the remote git server after every push from the client will be introduced. After the client pushing to the git server, several actions are triggered. These actions are done by hooks. Hooks are scripts placed in $GIT_DIR/hooks directory. One of the trigger action [...]]]></description>
			<content:encoded><![CDATA[<p>A method to send email notification to a list email addresses by the remote git server after every push from the client will be introduced.</p>
<p>After the client pushing to the git server, several actions are triggered. These actions are done by hooks. Hooks are scripts placed in $GIT_DIR/hooks directory. One of the trigger action is post-receive,  so we can put a executable script with name <em>post-receive</em> under $GIT_DIR/hooks. For every push by client, <em>post-receive</em> will be executed to send email notification.</p>
<p><a href="http://picasaweb.google.com/lh/photo/RAOIIBoAvy4hG6qisD28Lg?feat=embedwebsite" rel="nofollow"><img class="alignright" style="margin: 0 0 10px 10px" src="http://lh6.ggpht.com/_9GCSB4c6Upw/TAnhhfdzTlI/AAAAAAAAA7o/m9UolaAxqmQ/s400/git-commit-email.png" alt="" width="400" height="359" /></a>A sample notification email after client pushing two commits is show in the graph on the right. The subject contains a prefix, the repository name and the last commit message. The body of the email contains the commit log and summary of the changes.</p>
<p>Now lets go to the detail of configuring the mechanism.</p>
<h3>Get the post-receive script</h3>
<p>My script that sends email like the example described above can be downloaded from: <a href="http://fclose.com/t/go/post-receive-1-0/" rel="nofollow">git post-receive script.</a></p>
<p>Or view the source code:<a href="http://fclose.com/t/go/post-receive-github/" rel="nofollow external"> git post-receive script</a></p>
<p>This script use smtp server to send email. You need to change the smtp server address at the end of the script. Simply change smtp=&#8221;smtp://smtp.cse.ust.hk&#8221; to the smtp server you use. You can not use my smtp server which is only allowed to send email without authorization inside of CSD in HKUST. If you like to use Gmail&#8217;s smtp, please refer to <a href="1411/linux-sending-email-from-mailx-command-on-linux-using-gmails-smtp/" target="_blank">Sending Email from mailx Command on Linux Using Gmail’s Smtp.</a></p>
<p>This script is changed from Andy Parkins&#8217;s one which is in git&#8217;s distribution. On fedora 12, the original script can be found under /usr/share/git-core/contrib/hooks.</p>
<h3>Put post-receive into hooks directory</h3>
<p>After getting the <em>post-receive</em> script, you need to copy it to $GIT_DIR/hooks/ directory on the git server. $GIT_DIR means the repository root directory here.</p>
<p>Please note that this script should be executable. You may need to add executable mod bits to <em>post-receive</em> by</p>
<pre>chmod a+x hooks/post-receive</pre>
<p>when you are in $GIT_DIR.</p>
<h3>Change repository description</h3>
<p>The repository name in the email subject is the first line of $GIT_DIR/description. Change the first line of the description file to you project&#8217;s name.</p>
<h3>Change config</h3>
<p>The sender&#8217;s email address, the mail list and the subject prefix is defined in $GIT_DIR/config file. I like to edit this config file by hand which is as easy as using git config command.</p>
<p>Add these line to the config file:</p>
<pre>[hooks]
 mailinglist = "email1@example.com email2@example.com"
 senderemail = "owner@exmaple.com"</pre>
<p>The email addressed in mailing list is separated by space.</p>
<p>The default subject prefix is [GIT]. You can change it to any string you like by add hooks.emailprefix in config.</p>
<p>Now the email notification mechanism has been set up. You can change the script if more functions is needed.</p>
<p><span style="font-size: x-small;">Updated on Apr. 20, 2010. change &#8220;postreceive&#8221; to &#8220;post-receive&#8221; in &#8220;chmod&#8221; part.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://fclose.com/b/linux/1473/setting-up-git-commit-email-notification/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

