View Source

<h2>Initial Setup</h2>

<p>First, make sure you know the email address associated with your JIRA credentials. All commits pushed to the master repository are checked against these addresses, so your repository will need to be configured to use that address. The following will give you that information:</p>

<ul>
<li>Visit the ZF Crowd install: <a class="external-link" href="http://framework.zend.com/crowd">http://framework.zend.com/crowd</a></li>
<li>Log in, if you aren't.</li>
<li>Find the &quot;My Profile&quot; link in the upper right of the page, and follow it.</li>
<li>The resulting page will display your profile, including the <em>email</em> address with which you are registered. Make a note of it.</li>
</ul>


<ac:macro ac:name="note"><ac:parameter ac:name="title">Windows Users</ac:parameter><ac:rich-text-body>
<p>If you use Windows, and are unfamiliar with using Git or using Git on Windows, we recommend reading <a href="http://help.github.com/win-set-up-git/">the illustrated guide to git on windows</a>.</p></ac:rich-text-body></ac:macro>

<h3>Setup your own public repository</h3>

<p>Your next step is to establish a public repository from which we can pull your work into the master repository. You have two options: use github or other public site, or setup/use your own repository.</p>

<h4>Option 1: GitHub</h4>

<ul>
<li>Setup a <a href="http://github.com/">GitHub</a> account, if you haven't yet</li>
<li>Fork the <a href="http://github.com/zendframework/zf2">ZF2 repository</a></li>
<li>Setup an ssh key for github to use (if you haven't yet), using this explanation: <a class="external-link" href="http://help.github.com/linux-key-setup/">http://help.github.com/linux-key-setup/</a></li>
<li>Clone your fork locally and enter it (use your own GitHub username in the statement below)
<ac:macro ac:name="code"><ac:default-parameter>sh</ac:default-parameter><ac:plain-text-body><![CDATA[
% git clone git@github.com:<username>/zf2.git
% cd zf2
]]></ac:plain-text-body></ac:macro></li>
<li>Configure git to use the email address with which you are registered in JIRA:
<ac:macro ac:name="code"><ac:default-parameter>sh</ac:default-parameter><ac:plain-text-body><![CDATA[
% git config user.email <your email address>
]]></ac:plain-text-body></ac:macro></li>
<li>Add a remote to the canonical ZF repository (or GitHub mirror), so you can keep your fork up-to-date:
<ac:macro ac:name="code"><ac:default-parameter>sh</ac:default-parameter><ac:plain-text-body><![CDATA[
% git remote add zf2 git://github.com/zendframework/zf2.git
- AND -
% git fetch zf2
]]></ac:plain-text-body></ac:macro></li>
</ul>


<h4>Option 2: Personal Repository</h4>

<p>We assume you will use <a href="http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way">gitosis</a> or <a href="http://progit.org/book/ch4-8.html">gitolite</a> to host your own repository. If you go this route, we will assume you have the knowledge to do so, or know where to obtain it. We will not assist you in setting up such a repository.</p>

<ul>
<li>Create a new repository
<ac:macro ac:name="code"><ac:default-parameter>sh</ac:default-parameter><ac:plain-text-body><![CDATA[
% git init
]]></ac:plain-text-body></ac:macro></li>
<li>Configure git to use the email address with which you are registered in JIRA:
<ac:macro ac:name="code"><ac:default-parameter>sh</ac:default-parameter><ac:plain-text-body><![CDATA[
% git config user.email <your email address>
]]></ac:plain-text-body></ac:macro></li>
<li>Add an &quot;origin&quot; remote pointing to your gitosis/gitolite repo:
<ac:macro ac:name="code"><ac:default-parameter>sh</ac:default-parameter><ac:plain-text-body><![CDATA[
% git remote add origin git://yourdomain/yourrepo.git
]]></ac:plain-text-body></ac:macro></li>
<li>Add a remote for the ZF repository and fetch it
<ac:macro ac:name="code"><ac:default-parameter>sh</ac:default-parameter><ac:plain-text-body><![CDATA[
% git remote add zf2 git://git.zendframework.com/zf.git
% git fetch zf2
]]></ac:plain-text-body></ac:macro></li>
<li>Create a new branch for the ZF repository (named &quot;zf/master&quot; here)
<ac:macro ac:name="code"><ac:default-parameter>sh</ac:default-parameter><ac:plain-text-body><![CDATA[
% git branch -b zf/master zf2/master
]]></ac:plain-text-body></ac:macro></li>
<li>Create your master branch off the ZF branch, and push to your repository
<ac:macro ac:name="code"><ac:default-parameter>sh</ac:default-parameter><ac:plain-text-body><![CDATA[
% git branch -b master
% git push origin HEAD:master
]]></ac:plain-text-body></ac:macro></li>
</ul>


<h2>Keeping Up-to-Date</h2>

<p>Periodically, you should update your fork or personal repository to match the canonical ZF repository. In each of the above setups, we have added a remote to the Zend Framework repository, which allows you to do the following:</p>

<ac:macro ac:name="code"><ac:default-parameter>sh</ac:default-parameter><ac:plain-text-body><![CDATA[
% git checkout master
% git pull zf2 master
- OPTIONALLY, to keep your remote up-to-date -
% git push origin
]]></ac:plain-text-body></ac:macro>

<h2>Working on Zend Framework</h2>

<p>When working on Zend Framework, we recommend you do each new feature or bugfix in a new branch. This simplifies the task of code review as well as of merging your changes into the canonical repository.</p>

<p>A typical work flow will then consist of the following:</p>

<ul>
<li>Create a new local branch based off your master branch.</li>
<li>Switch to your new local branch. (This step can be combined with the previous step with the use of `git checkout -b`.)</li>
<li>Do some work, commit, repeat as necessary.</li>
<li>Push the local branch to your remote repository.</li>
<li>Send a pull request.</li>
</ul>


<p>We recommend naming your branches as follows:</p>

<ul>
<li>&quot;hotfix/&lt;issue ID&gt;&quot; for bugfixes; e.g. &quot;hotfix/ZF-9295&quot;</li>
<li>&quot;feature/&lt;feature name&gt;&quot; for features; e.g., &quot;feature/translate-resource-es&quot;</li>
</ul>


<p>The mechanics of this process are actually quite trivial. Below, we will create a branch for fixing an issue in the tracker.</p>
<ac:macro ac:name="code"><ac:default-parameter>sh</ac:default-parameter><ac:plain-text-body><![CDATA[
% git checkout -b hotfix/ZF-9295
Switched to a new branch 'hotfix/ZF-9295'

... do some work ...

% git commit

... write your log message ...

% git push origin hotfix/ZF-9295:hotfix/ZF-9295
Counting objects: 38, done.
Delta compression using up to 2 threads.
Compression objects: 100% (18/18), done.
Writing objects: 100% (20/20), 8.19KiB, done.
Total 20 (delta 12), reused 0 (delta 0)
To ssh://git@github.com/weierophinney/zf2.git
b5583aa..4f51698 HEAD -> master
]]></ac:plain-text-body></ac:macro>

<p>To send a pull request, you have two options.</p>

<p>If using GitHub, you can do the pull request from there. Navigate to your repository, select the branch you just created, and then select the &quot;Pull Request&quot; button in the upper right. Select the user &quot;zendframework&quot; as the recipient.</p>

<p>If using your own repository - or even if using GitHub - you can send an email indicating you have changes to pull:</p>

<ul>
<li>Send to <a class="external-link" href="mailto:zf-devteam@zend.com">zf-devteam@zend.com</a></li>
<li>In your message, specify:
<ul>
<li>The URL to your repository (e.g., &quot;git://mwop.net/zf2.git&quot;)</li>
<li>The branch containing the changes you want pulled (e.g., &quot;hotfix/ZF-9295&quot;)</li>
<li>The nature of the changes (e.g., &quot;implements Zend_Service_Twitter&quot;, &quot;fixes ZF-9295&quot;, etc.)</li>
</ul>
</li>
</ul>


<p>In order to generate the pull request message automatically <a href="http://www.kernel.org/pub/software/scm/git/docs/git-request-pull.html">git-request-pull</a> may be used. </p>

<p>For example, to ask to pull changes from <strong>milestones/exceptions/slideshare</strong> branch on your github fork <strong>git@github.com:USERNAME/zf2.git</strong> into <strong>zf2/milestones/exceptions</strong>:</p>

<ac:macro ac:name="code"><ac:default-parameter>sh</ac:default-parameter><ac:plain-text-body><![CDATA[
% git request-pull zf2/milestones/exceptions git@github.com:USERNAME/zf2.git milestones/exceptions/slideshare
]]></ac:plain-text-body></ac:macro>

<p>The above will generate message you can send to <a class="external-link" href="mailto:zf-devteam@zend.com">zf-devteam@zend.com</a>, it has all necessary bits of information injected.</p>

<h2>Branch Cleanup</h2>

<p>As you might imagine, if you are a frequent contributor, you'll start to get a ton of branches both locally and on your remote.</p>

<p>Once you know that your changes have been accepted to the master repository, we suggest doing some cleanup of these branches.</p>

<ul>
<li>Local branch cleanup
<ac:macro ac:name="code"><ac:default-parameter>sh</ac:default-parameter><ac:plain-text-body><![CDATA[
% git branch -d <branchname>
]]></ac:plain-text-body></ac:macro></li>
<li>Remote branch removal
<ac:macro ac:name="code"><ac:default-parameter>sh</ac:default-parameter><ac:plain-text-body><![CDATA[
% git push origin :<branchname>
]]></ac:plain-text-body></ac:macro></li>
</ul>


<h2>Feeds and Emails</h2>

<p>RSS feeds may be found at:</p>

<ul>
<li><a class="external-link" href="https://github.com/zendframework/zf2/commits/">https://github.com/zendframework/zf2/commits/</a>&lt;branch&gt;.atom</li>
</ul>


<p>where &lt;branch&gt; is a branch in the repository.</p>

<p>To subscribe to git email notifications, send an email to:</p>

<ul>
<li><a class="external-link" href="mailto:zf-git-subscribe@lists.zend.com">zf-git-subscribe@lists.zend.com</a></li>
</ul>


<p>You will need to reply to the verification email sent to you by this list.</p>

<p>Should you wish to filter emails from the list, they will use the &quot;subject&quot; line of commit messages, preceded by &quot;<ac:link><ri:page ri:content-title="branch" /></ac:link> &quot;, and come from &quot;zf-git@lists.zend.com&quot;.</p>