<?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>nvie.com &#187; Git</title>
	<atom:link href="http://nvie.com/archives/category/git/feed" rel="self" type="application/rss+xml" />
	<link>http://nvie.com</link>
	<description>Anything that interests me.</description>
	<lastBuildDate>Tue, 24 Aug 2010 11:21:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>An upgrade of gitflow</title>
		<link>http://nvie.com/archives/492</link>
		<comments>http://nvie.com/archives/492#comments</comments>
		<pubDate>Thu, 04 Mar 2010 00:44:20 +0000</pubDate>
		<dc:creator>Vincent Driessen</dc:creator>
				<category><![CDATA[Git]]></category>
		<category><![CDATA[gitflow]]></category>

		<guid isPermaLink="false">http://nvie.com/?p=492</guid>
		<description><![CDATA[Last week, I silently tagged gitflow 0.2. The most important changes since 0.1 are: Order of arguments changed to have a more &#8220;gitish&#8221; subcommand structure. For example, you now say: git flow feature start myfeature Better initializer. git flow init now prompts interactively to set up a gitflow enabled repo. Added a command to list [...]]]></description>
			<content:encoded><![CDATA[<p>Last week, I silently tagged <a href="http://github.com/nvie/gitflow/tree/0.2">gitflow 0.2</a>. The most important changes since 0.1 are:</p>
<ul>
<li>Order of arguments changed to have a more &#8220;gitish&#8221; subcommand structure. For example, you now say:
<pre>git flow feature start myfeature</pre>
</li>
<li>Better initializer. <code>git flow init</code> now prompts interactively to set up a gitflow enabled repo.</li>
<li>Added a command to list all feature/release/hotfix/support branches, e.g.:
<pre>git flow feature list</pre>
</li>
<li>Made all merge/rebase operations failsafe, providing a non-destructive workflow in case of merge conflicts.</li>
<li>Easy diff&#8217;ing of all changes on a specific (or the current) feature branch:
<pre>git flow feature diff [feature]</pre>
</li>
<li>Add support for feature branch rebasing:
<pre>git flow feature rebase</pre>
</li>
<li>Some subactions now take name prefixes as their arguments, for convenience. For example, if you have feature branches called &#8220;experimental&#8221;, &#8220;refactoring&#8221; and &#8220;feature-X&#8221;, you could say:
<pre>git flow feature finish ref</pre>
<p>And gitflow will know you mean the &#8220;refactoring&#8221; feature branch.</p>
<p>These actions are: <code>finish</code>, <code>diff</code> and <code>rebase</code>.</li>
<li>Much better overall sanity checking.</li>
<li>Better portability (POSIX compliant code)</li>
<li>Better (more portable) flag parsing using Kate Ward&#8217;s <a href="http://code.google.com/p/shflags/">shFlags</a>.</li>
<li>Improved installer. To install <code>git flow</code> as a first-class Git subcommand, simply type:
<pre>sudo make install</pre>
</li>
<li>Major and minor bug fixes.</li>
</ul>
<p>That&#8217;s all for now.</p>
]]></content:encoded>
			<wfw:commentRss>http://nvie.com/archives/492/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>gitflow 0.1 released</title>
		<link>http://nvie.com/archives/438</link>
		<comments>http://nvie.com/archives/438#comments</comments>
		<pubDate>Tue, 26 Jan 2010 12:49:56 +0000</pubDate>
		<dc:creator>Vincent Driessen</dc:creator>
				<category><![CDATA[Git]]></category>
		<category><![CDATA[gitflow]]></category>

		<guid isPermaLink="false">http://nvie.com/?p=438</guid>
		<description><![CDATA[After the overwhelming attention and feedback on the Git branching model post, a general consensus was that this workflow would benefit from some form of proper scriptability. The workflow works seamlessly if you perform the steps involved manually, but hey&#8230; manually is manually, really. UPDATE 2/4/2010: Anyone reading this: I recommend NOT USING this very [...]]]></description>
			<content:encoded><![CDATA[<p>After the overwhelming attention and feedback on the <a href="/archives/323">Git branching model post</a>, a general consensus was that this workflow would benefit from some form of proper scriptability. The workflow works seamlessly if you perform the steps involved manually, but hey&#8230; manually is manually, really.</p>
<blockquote><p><ins datetime="2010-02-04T11:10:19+00:00"><strong>UPDATE 2/4/2010</strong>:<br />
Anyone reading this: I recommend NOT USING this very early release, but to jump on the <a href="http://github.com/nvie/gitflow/tree/develop">current develop tip</a>, which is much more mature. Release 0.2 is coming very soon.</ins></p></blockquote>
<p>An assisting tool (dubbed <code>gitflow</code>) was therefore created to provide simple, high-level commands to adopt the workflow into your own software development process. It&#8217;s free and it&#8217;s open source. Feel free to contribute to it if you like.</p>
<blockquote><p>Fork me on Github:<br />
<a href="http://github.com/nvie/gitflow">http://github.com/nvie/gitflow</a></p></blockquote>
<p>Since this morning, the first working <a href="http://github.com/nvie/gitflow/downloads">release 0.1</a> was tagged, albeit very basic.</p>
<h3>A quick walkthrough</h3>
<p>The <code>gitflow</code> script essentially features six subcommands: paired start/finish commands for managing the different types of branches from the originating article:</p>
<ul>
<li>Feature branches
<ul>
<li><code>gitflow start feature <em>myfeature</em></code></li>
<li><code>gitflow finish feature <em>myfeature</em></code></li>
</ul>
</li>
<li>Release branches
<ul>
<li><code>gitflow start release <em>version-id</em></code></li>
<li><code>gitflow finish release <em>version-id</em></code></li>
</ul>
</li>
<li>Hotfix branches
<ul>
<li><code>gitflow start hotfix <em>version-id</em></code></li>
<li><code>gitflow finish hotfix <em>version-id</em></code></li>
</ul>
</li>
</ul>
<p>Each of these scripts exactly reports what actions were taken and what follow-up actions are required by the user. This output will be polished in future versions to improve the <a href="http://en.wikipedia.org/wiki/User_experience_design">UX</a>. An example output:</p>
<pre>
<strong>$ gitflow finish feature foo</strong>
Branches 'develop' and 'origin/develop' have diverged.
And local branch 'develop' is ahead of 'origin/develop'.
Switched to branch "develop"
Your branch is ahead of 'origin/develop' by 12 commits.
Merge made by recursive.
 README |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
Deleted branch foo (cd3effb).

Summary of actions:
- The feature branch 'foo' was merged into 'develop'
- Feature branch 'foo' has been removed
- You are now on branch 'develop'
</pre>
<h3>Limitations</h3>
<p>The script is very limited at the moment yet, but future versions will fix that, too. Some of the main limitations:</p>
<ul>
<li>Branch names (<code>master</code>, <code>develop</code>) and the remote repo name (<code>origin</code>) are currently fixed.</li>
<li>There is no support for dealing with merge conflicts yet.</li>
<li>There is no support for <code>support-*</code> branches (see the <a href="/archives/323#comment-185">original comment</a> that proposed this extension)</li>
<li>There is no documentation.</li>
<li>There is no installer.</li>
</ul>
<p>However, as this post is written, some of the limitations are already taken care of by community members. Power to the open source!</p>
]]></content:encoded>
			<wfw:commentRss>http://nvie.com/archives/438/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Building Git from scratch on Snow Leopard</title>
		<link>http://nvie.com/archives/420</link>
		<comments>http://nvie.com/archives/420#comments</comments>
		<pubDate>Tue, 12 Jan 2010 23:29:24 +0000</pubDate>
		<dc:creator>Vincent Driessen</dc:creator>
				<category><![CDATA[Git]]></category>

		<guid isPermaLink="false">http://nvie.com/?p=420</guid>
		<description><![CDATA[When you try to build Git from scratch on a Snow Leopard machine, you may have ran into the following problem: $ git clone git://github.com/git/git.git Initialized empty Git repository in /Users/nvie/git/.git/ remote: Counting objects: 111619, done. remote: Compressing objects: 100% (28007/28007), done. remote: Total 111619 (delta 82192), reused 111264 (delta 81852) Receiving objects: 100% (111619/111619), [...]]]></description>
			<content:encoded><![CDATA[<p>When you try to build Git <a href="http://github.com/git/git">from scratch</a> on a Snow Leopard machine, you may have ran into the following problem:</p>
<pre><strong>$ git clone git://github.com/git/git.git</strong>
Initialized empty Git repository in /Users/nvie/git/.git/
remote: Counting objects: 111619, done.
remote: Compressing objects: 100% (28007/28007), done.
remote: Total 111619 (delta 82192), reused 111264 (delta 81852)
Receiving objects: 100% (111619/111619), 27.60 MiB | 531 KiB/s, done.
Resolving deltas: 100% (82192/82192), done.
<strong>$ cd git</strong>
<strong>$ make prefix=/usr/local/bin/git</strong>
GIT_VERSION = 1.6.2.rc0.90.g0753
    * new build flags or prefix
    CC fast-import.o
    CC abspath.o
    :
    :
<span style="color: #ff0000;">ld: warning: in /opt/local/lib/libexpat.dylib, file is not of required architecture</span>
<span style="color: #ff0000;">    ...
ld: symbol(s) not found
collect2: ld returned 1 exit status
</span></pre>
<p>Then, you have a pretty big change you are having an old Darwin ports (<a href="http://www.macports.org">macports</a>) collection in use which has not yet been upgraded to Snow Leopard&#8217;s new x64 architecture.</p>
<p>There is, however, a simple solution to this, namely to have the <code>git</code> build ignore the Darwin ports, simply by adding the following parameter to the build:</p>
<pre><strong>$ make <span style="color: #008000;">NO_DARWIN_PORTS=1</span> prefix=/usr/local/bin/git</strong></pre>
]]></content:encoded>
			<wfw:commentRss>http://nvie.com/archives/420/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A successful Git branching model</title>
		<link>http://nvie.com/git-model</link>
		<comments>http://nvie.com/git-model#comments</comments>
		<pubDate>Tue, 05 Jan 2010 07:49:34 +0000</pubDate>
		<dc:creator>Vincent Driessen</dc:creator>
				<category><![CDATA[Git]]></category>
		<category><![CDATA[gitflow]]></category>

		<guid isPermaLink="false">http://nvie.com/?p=323</guid>
		<description><![CDATA[In this post I present the development model that I&#8217;ve introduced for all of my projects (both at work and private) about a year ago, and which has turned out to be very successful. I&#8217;ve been meaning to write about it for a while now, but I&#8217;ve never really found the time to do so thoroughly, [...]]]></description>
			<content:encoded><![CDATA[<p>In this post I present the development model that I&#8217;ve introduced for all of my projects (both at work and private) about a year ago, and which has turned out to be very successful. I&#8217;ve been meaning to write about it for a while now, but I&#8217;ve never really found the time to do so thoroughly, until now. I won&#8217;t talk about any of the projects&#8217; details, merely about the branching strategy and release management.</p>
<p style="text-align: center;"><img class="size-full wp-image-344 aligncenter" title="The branches of the branching model" src="http://nvie.com/wp-content/uploads/2009/12/Screen-shot-2009-12-24-at-11.32.03.png" alt="" width="611" height="815" /></p>
<p><span id="more-323"></span></p>
<p>It focuses around <a href="http://git-scm.com">Git</a> as the tool for the versioning of all of our source code.</p>
<h2>Why git?</h2>
<p>For a thorough discussion on the pros and cons of Git compared to centralized source code control systems, <a href="http://whygitisbetterthanx.com/">see</a> <a href="http://www.looble.com/git-vs-svn-which-is-better/">the</a> <a href="http://git.or.cz/gitwiki/GitSvnComparsion">web</a>. There are plenty of flame wars going on there. As a developer, I prefer Git above all other tools around today. Git really changed the way developers think of merging and branching. From the classic CVS/Subversion world I came from, merging/branching has always been considered a bit scary (&#8220;beware of merge conflicts, they bite you!&#8221;) and something you only do every once in a while.</p>
<p>But with Git, these actions are extremely cheap and simple, and they are considered one of the core parts of your <em>daily</em> workflow, really. For example, in CVS/Subversion <a href="http://svnbook.red-bean.com">books</a>, branching and merging is first discussed in the later chapters (for advanced users), while in <a href="http://book.git-scm.com">every</a> <a href="http://pragprog.com/titles/tsgit/pragmatic-version-control-using-git">Git</a> <a href="http://github.com/progit/progit">book</a>, it&#8217;s already covered in chapter 3 (basics).</p>
<p>As a consequence of its simplicity and repetitive nature, branching and merging are no longer something to be afraid of. Version control tools are supposed to assist in branching/merging more than anything else.</p>
<p>Enough about the tools, let&#8217;s head onto the development model.  The model that I&#8217;m going to present here is essentially no more than a set of procedures that every team member has to follow in order to come to a managed software development process.</p>
<h2>Decentralized but centralized</h2>
<p>The repository setup that we use and that works well with this branching model, is that with a central &#8220;truth&#8221; repo. Note that this repo is only <em>considered</em> to be the central one (since Git is a DVCS, there is no such thing as a central repo at a technical level). We will refer to this repo as <code>origin</code>, since this name is familiar to all Git users.</p>
<p style="text-align: center;"><a href="http://nvie.com/wp-content/uploads/2010/01/centr-decentr.png"><img class="alignnone size-full wp-image-413" title="Centralised, yet decentralised" src="http://nvie.com/wp-content/uploads/2010/01/centr-decentr.png" alt="" width="478" height="356" /></a></p>
<p>Each developer pulls and pushes to origin. But besides the centralized push-pull relationships, each developer may also pull changes from other peers to form sub teams. For example, this might be useful to work together with two or more developers on a big new feature, before pushing the work in progress to <code>origin</code> prematurely. In the figure above, there are subteams of Alice and Bob, Alice and David, and Clair and David.</p>
<p>Technically, this means nothing more than that Alice has defined a Git remote, named <code>bob</code>, pointing to Bob&#8217;s repository, and vice versa.</p>
<h2>The main branches</h2>
<p><img class="size-full wp-image-348 alignright" title="Master-develop cycle" src="http://nvie.com/wp-content/uploads/2009/12/bm002.png" alt="" width="254" height="378" /></p>
<p>At the core, the development model is greatly inspired by existing models out there. The central repo holds two main branches with an infinite lifetime:</p>
<ul>
<li><code>master</code></li>
<li><code>develop</code></li>
</ul>
<p>The <code>master</code> branch at <code>origin</code> should be familiar to every Git user. Parallel to the <code>master</code> branch, another branch exists called <code>develop</code>.</p>
<p>We consider <code>origin/master</code> to be the main branch where the source code of <code>HEAD</code> always reflects a <em>production-ready</em> state.</p>
<p>We consider <code>origin/develop</code> to be the main branch where the source code of <code>HEAD</code> always reflects a state with the latest delivered development changes for the next release. Some would call this the &#8220;integration branch&#8221;. This is where any automatic nightly builds are built from.</p>
<p>When the source code in the <code>develop</code> branch reaches a stable point and is ready to be released, all of the changes should be merged back into <code>master</code> somehow and then tagged with a release number. How this is done in detail will be discussed further on.</p>
<p>Therefore, each time when changes are merged back into <code>master</code>, this is a new production release <em>by definition</em>. We tend to be very strict at this, so that theoretically, we could use a Git hook script to automatically build and roll-out our software to our production servers everytime there was a commit on <code>master</code>.</p>
<h2>Supporting branches</h2>
<p>Next to the main branches <code>master</code> and <code>develop</code>, our development model uses a variety of supporting branches to aid parallel development between team members, ease tracking of features, prepare for production releases and to assist in quickly fixing live production problems. Unlike the main branches, these branches always have a limited life time, since they will be removed eventually.</p>
<p>The different types of branches we may use are:</p>
<ul>
<li>Feature branches</li>
<li>Release branches</li>
<li>Hotfix branches</li>
</ul>
<p>Each of these branches have a specific purpose and are bound to strict rules as to which branches may be their originating branch and which branches must be their merge targets. We will walk through them in a minute.</p>
<p>By no means are these branches &#8220;special&#8221; from a technical perspective. The branch types are categorized by how we <em>use</em> them. They are of course plain old Git branches.</p>
<h3>Feature branches</h3>
<p><img class="alignright size-full wp-image-368" title="Feature branch" src="http://nvie.com/wp-content/uploads/2009/12/fb.png" alt="" width="133" height="352" />May branch off from: <code>develop</code></p>
<p>Must merge back into: <code>develop</code></p>
<p>Branch naming convention: anything except <code>master</code>, <code>develop</code>, <code>release-*</code>, or <code>hotfix-*</code></p>
<p>Feature branches (or sometimes called topic branches) are used to develop new features for the upcoming or a distant future release. When starting development of a feature, the target release in which this feature will be incorporated may well be unknown at that point. The essence of a feature branch is that it exists as long as the feature is in development, but will eventually be merged back into <code>develop</code> (to definitely add the new feature to the upcoming release) or discarded (in case of a disappointing experiment).</p>
<p>Feature branches typically exist in developer repos only, not in <code>origin</code>.</p>
<h4>Creating a feature branch</h4>
<p>When starting work on a new feature, branch off from the <code>develop</code> branch.</p>
<pre><strong>$ git checkout -b myfeature develop</strong>
Switched to a new branch "myfeature"</pre>
<h4>Incorporating a finished feature on develop</h4>
<p>Finished features may be merged into the <code>develop</code> branch definitely add them to the upcoming release:</p>
<pre><strong>$ git checkout develop</strong>
Switched to branch 'develop'
<strong>$ git merge --no-ff myfeature</strong>
Updating ea1b82a..05e9557
<em>(Summary of changes)</em>
<strong>$ git branch -d myfeature</strong>
Deleted branch myfeature (was 05e9557).
<strong>$ git push origin develop</strong></pre>
<p>The <code>--no-ff</code> flag causes the merge to always create a new commit object, even if the merge could be performed with a fast-forward. This avoids losing information about the historical existence of a feature branch and groups together all commits that together added the feature. Compare:</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-394" title="Merging with or without fast-forwards" src="http://nvie.com/wp-content/uploads/2010/01/merge-without-ff.png" alt="" width="463" height="414" /></p>
<p>In the latter case, it is impossible to see from the Git history which of the commit objects together have implemented a feature—you would have to manually read all the log messages. Reverting a whole feature (i.e. a group of commits), is a true headache in the latter situation, whereas it is easily done if the <code>--no-ff</code> flag was used.</p>
<p>Yes, it will create a few more (empty) commit objects, but the gain is much bigger that that cost.</p>
<p>Unfortunately, I have not found a way to make <code>--no-ff</code> the default behaviour of <code>git merge</code> yet, but it really should be.</p>
<h3>Release branches</h3>
<p>May branch off from: <code>develop</code></p>
<p>Must merge back into: <code>develop</code> and <code>master</code></p>
<p>Branch naming convention: <code>release-*</code></p>
<p>Release branches support preparation of a new production release. They allow for last-minute dotting of i&#8217;s and crossing t&#8217;s. Furthermore, they allow for minor bug fixes and preparing meta-data for a release (version number, build dates, etc.). By doing all of this work on a release branch, the <code>develop</code> branch is cleared to receive features for the next big release.</p>
<p>The key moment to branch off a new release branch from <code>develop</code> is when develop (almost) reflects the desired state of the new release. At least all features that are targeted for the release-to-be-built must be merged in to <code>develop</code> at this point in time. All features targeted at future releases may not—they must wait until after the release branch is branched off.</p>
<p>It is exactly at the start of a release branch that the upcoming release gets assigned a version number—not any earlier. Up until that moment, the <code>develop</code> branch reflected changes for the &#8220;next release&#8221;, but it is unclear whether that &#8220;next release&#8221; will eventually become 0.3 or 1.0, until the release branch is started. That decision is made on the start of the release branch and is carried out by the project&#8217;s rules on version number bumping.</p>
<h4>Creating a release branch</h4>
<p>Release branches are created from the <code>develop</code> branch. For example, say version 1.1.5 is the current production release and we have a big release coming up. The state of <code>develop</code> is ready for the &#8220;next release&#8221; and we have decided that this will become version 1.2 (rather than 1.1.6 or 2.0). So we branch off and give the release branch a name reflecting the new version number:</p>
<pre><strong>$ git checkout -b release-1.2 develop</strong>
Switched to a new branch "release-1.2"
<strong>$ ./bump-version.sh 1.2</strong>
Files modified successfully, version bumped to 1.2.
<strong>$ git commit -a -m "Bumped version number to 1.2"</strong>
[release-1.2 74d9424] Bumped version number to 1.2
1 files changed, 1 insertions(+), 1 deletions(-)</pre>
<p>After creating a new branch and switching to it, we bump the version number. Here, <code>bump-version.sh</code> is a fictional shell script that changes some files in the working copy to reflect the new version. (This can of course be a manual change—the point being that <em>some</em> files change.) Then, the bumped version number is committed.</p>
<p>This new branch may exist there for a while, until the release may be rolled out definitely. During that time, bug fixes may be applied in this branch (rather than on the <code>develop</code> branch). Adding large new features here is strictly prohibited. They must be merged into <code>develop</code>, and therefore, wait for the next big release.</p>
<h4>Finishing a release branch</h4>
<p>When the state of the release branch is ready to become a real release, some actions need to be carried out. First, the release branch is merged into <code>master</code> (since every commit on <code>master</code> is a new release <em>by definition</em>, remember). Next, that commit on <code>master</code> must be tagged for easy future reference to this historical version. Finally, the changes made on the release branch need to be merged back into <code>develop</code>, so that future releases also contain these bug fixes.</p>
<p>The first two steps in Git:</p>
<pre><strong>$ git checkout master</strong>
Switched to branch 'master'
<strong>$ git merge --no-ff release-1.2
</strong>Merge made by recursive.
<em>(Summary of changes)</em>
<strong>$ git tag -a 1.2</strong></pre>
<p>The release is now done, and tagged for future reference.<br />
<ins datetime="2010-02-06T12:31:04+00:00"><strong>Edit:</strong> You might as well want to use the <code>-s</code> or <code>-u &lt;key&gt;</code> flags to sign your tag cryptographically.</ins></p>
<p>To keep the changes made in the release branch, we need to merge those back into <code>develop</code>, though. In Git:</p>
<pre><strong>$ git checkout develop</strong>
Switched to branch 'develop'
<strong>$ git merge --no-ff release-1.2
</strong>Merge made by recursive.
<em>(Summary of changes)</em></pre>
<p>This step may well lead to a merge conflict (probably even, since we have changed the version number). If so, fix it and commit.</p>
<p>Now we are really done and the release branch may be removed, since we don&#8217;t need it anymore:</p>
<pre><strong>$ git branch -d release-1.2</strong>
Deleted branch release-1.2 (was ff452fe).</pre>
<h3>Hotfix branches</h3>
<p><img class="alignright size-full wp-image-390" title="Hotfix branching" src="http://nvie.com/wp-content/uploads/2010/01/hotfix-branches1.png" alt="" width="307" height="422" />May branch off from: <code>master</code></p>
<p>Must merge back into: <code>develop</code> and <code>master</code></p>
<p>Branch naming convention: <code>hotfix-*</code></p>
<p>Hotfix branches are very much like release branches in that they are also meant to prepare for a new production release, albeit unplanned. They arise from the necessity to act immediately upon an undesired state of a live production version. When a critical bug in a production version must be resolved immediately, a hotfix branch may be branched off from the corresponding tag on the master branch that marks the production version.</p>
<p>The essence is that work of team members (on the <code>develop</code> branch) can continue, while another person is preparing a quick production fix.</p>
<h4>Creating the hotfix branch</h4>
<p>Hotfix branches are created from the <code>master</code> branch. For example, say version 1.2 is the current production release running live and causing troubles due to a severe bug. But changes on <code>develop</code> are yet unstable. We may then branch off a hotfix branch and start fixing the problem:</p>
<pre><strong>$ git checkout -b hotfix-1.2.1 master</strong>
Switched to a new branch "hotfix-1.2.1"
<strong>$ ./bump-version.sh 1.2.1</strong>
Files modified successfully, version bumped to 1.2.1.
<strong>$ git commit -a -m "Bumped version number to 1.2.1"</strong>
[hotfix-1.2.1 41e61bb] Bumped version number to 1.2.1
1 files changed, 1 insertions(+), 1 deletions(-)</pre>
<p>Don&#8217;t forget to bump the version number after branching off!</p>
<p>Then, fix the bug and commit the fix in one or more separate commits.</p>
<pre><strong>$ git commit -m "Fixed severe production problem"</strong>
[hotfix-1.2.1 abbe5d6] Fixed severe production problem
5 files changed, 32 insertions(+), 17 deletions(-)</pre>
<p><strong>Finishing a hotfix branch</strong></p>
<p>When finished, the bugfix needs to be merged back into <code>master</code>, but also needs to be merged back into <code>develop</code>, in order to safeguard that the bugfix is included in the next release as well. This is completely similar to how release branches are finished.</p>
<p>First, update <code>master</code> and tag the release.</p>
<pre><strong>$ git checkout master</strong>
Switched to branch 'master'
<strong>$ git merge --no-ff hotfix-1.2.1</strong>
Merge made by recursive.
<em>(Summary of changes)</em>
<strong>$ git tag -a 1.2.1</strong></pre>
<p><ins datetime="2010-02-06T12:31:04+00:00"><strong>Edit:</strong> You might as well want to use the <code>-s</code> or <code>-u &lt;key&gt;</code> flags to sign your tag cryptographically.</ins></p>
<p>Next, include the bugfix in <code>develop</code>, too:</p>
<pre><strong>$ git checkout develop</strong>
Switched to branch 'develop'
<strong>$ git merge --no-ff hotfix-1.2.1</strong>
Merge made by recursive.
<em>(Summary of changes)</em></pre>
<p>The one exception to the rule here is that, <strong>when a release branch currently exists, the hotfix changes need to be merged into that release branch, instead of </strong><code><strong>develop</strong></code>. Back-merging the bugfix into the release branch will eventually result in the bugfix being merged into <code>develop</code> too, when the release branch is finished. (If work in <code>develop</code> immediately requires this bugfix and cannot wait for the release branch to be finished, you may safely merge the bugfix into <code>develop</code> now already as well.)</p>
<p>Finally, remove the temporary branch:</p>
<pre><strong>$ git branch -d hotfix-1.2.1</strong>
Deleted branch hotfix-1.2.1 (was abbe5d6).</pre>
<h2>Summary</h2>
<p>While there is nothing really shocking new to this branching model, the &#8220;big picture&#8221; figure that this post began with has turned out to be tremendously useful in our projects. It forms an elegant mental model that is easy to comprehend and allows team members to develop a shared understanding of the branching and releasing processes.</p>
<p>A high-quality PDF version of the figure is provided here. Go ahead and hang it on the wall for quick reference at any time.</p>
<p><ins datetime="2010-05-03T17:50:14+00:00"><strong>Update:</strong> And for anyone who requested it: here&#8217;s the <a href="http://github.com/downloads/nvie/gitflow/Git-branching-model-src.key.zip">gitflow-model.src.key</a> of the main diagram image (Apple Keynote).</ins></p>
<table border="0">
<tbody>
<tr>
<td align="center"><a href="http://github.com/downloads/nvie/gitflow/Git-branching-model.pdf"><img class="alignnone size-full wp-image-383" title="Download PDF" src="http://nvie.com/wp-content/uploads/2010/01/pdf_icon.png" alt="" width="128" height="128" /></a></td>
</tr>
<tr>
<td align="center"><strong><a href="http://github.com/downloads/nvie/gitflow/Git-branching-model.pdf">Git-branching-model.pdf</a></strong></td>
</tr>
</tbody>
</table>
<p>Feel free to add your comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://nvie.com/git-model/feed</wfw:commentRss>
		<slash:comments>249</slash:comments>
		</item>
		<item>
		<title>Avoiding fast-forward merges in Git</title>
		<link>http://nvie.com/archives/319</link>
		<comments>http://nvie.com/archives/319#comments</comments>
		<pubDate>Sat, 19 Dec 2009 12:21:24 +0000</pubDate>
		<dc:creator>Vincent Driessen</dc:creator>
				<category><![CDATA[Git]]></category>

		<guid isPermaLink="false">http://nvie.com/?p=319</guid>
		<description><![CDATA[Just a pointer to an excellent post I wanted to share with you: In the section &#8220;Why we shouldn’t fast-forward&#8221; at http://robey.lag.net/2009/11/29/more-git.html, Robey explains very clearly how fast forwards effectively make you loose historical information that may be crucial to ever reconstruct or understand your own project&#8217;s history.]]></description>
			<content:encoded><![CDATA[<p>Just a pointer to an excellent post I wanted to share with you:</p>
<p>In the section &#8220;Why we shouldn’t fast-forward&#8221; at <a href="http://robey.lag.net/2009/11/29/more-git.html">http://robey.lag.net/2009/11/29/more-git.html</a>, Robey explains very clearly how fast forwards effectively make you loose historical information that may be crucial to ever reconstruct or understand your own project&#8217;s history.</p>
]]></content:encoded>
			<wfw:commentRss>http://nvie.com/archives/319/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
