<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Kleinsch</title>
	
	<link>http://kleinsch.com</link>
	<description>Nick Kleinschmidt's Blog</description>
	<lastBuildDate>Wed, 14 Jul 2010 13:19:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/kleinsch" /><feedburner:info uri="kleinsch" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Game Engine Design / iPhone Game Engine Resources</title>
		<link>http://feedproxy.google.com/~r/kleinsch/~3/JvOZvC9XSno/</link>
		<comments>http://kleinsch.com/2010/01/18/game-engine-design-iphone-game-engine-resources/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 00:55:37 +0000</pubDate>
		<dc:creator>Nick Kleinschmidt</dc:creator>
				<category><![CDATA[Game Engine]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[design]]></category>

		<guid isPermaLink="false">http://kleinsch.com/?p=223</guid>
		<description><![CDATA[I'm in the process of writing a simple game engine for the iPhone and have been doing a lot of research about game engine design. I also looked into using a prebuilt iPhone game engine, but decided I'm more interested in writing it myself (because of technical, business, and hacker ego reasons).  Here are some resources I found helpful.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m in the process of writing a simple game engine for the iPhone and have been doing a lot of research about game engine design. I also looked into using a prebuilt iPhone game engine, but decided I&#8217;m more interested in writing it myself (because of technical, business, and hacker ego reasons).  Here are some resources I found helpful.</p>
<p><strong>Books</strong><br />
<a href="http://www.amazon.com/gp/product/1568814135?ie=UTF8&amp;tag=kleinsch-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1568814135">Game Engine Architecture</a> &#8211; A textbook about game engine design, this presents options and tradeoffs for each piece of the engine. Light on actual coding, so you&#8217;ll have to be able to develop things yourself, but jam-packed with useful information. I found this invaluable while in the design stage.<br />
<a href="http://www.amazon.com/gp/product/1584506806?ie=UTF8&amp;tag=kleinsch-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1584506806">Game Coding Complete</a> &#8211; Walks through the process of building a game engine and using it to create a full-fledged game, complete with AI and multiplayer networking. Found it useful in tying the pieces together, but only presents one approach to most problems.</p>
<p><strong>Presentations</strong><br />
Gamasutra has all the <a href="http://www.gamasutra.com/gdcarchive/2000/index.htm">presentations</a> from the Game Developers Conference from 2000-2003 (Use the links in the sidebar to navigate year).<br />
Marcin Chady &#8211; <a href="http://cmpmedia.vo.llnwd.net/o1/vault/gdccanada09/slides/marcinchadyGDCCanada.ppt">Theory and Practice of Game Object Component Architecture</a> &#8211; The best presentation I found about component driven game object design.<br />
Alex Duran &#8211; <a href="http://www.gamasutra.com/gdcarchive/2003/Duran_Alex.ppt">Building Object Systems &#8211; Features, Tradeoffs, and Pitfalls</a><br />
Scott Bilas &#8211; <a href="www.allegro.cc/files/attachment/598187">A Data-Driven Game Object System</a><br />
Rob Fermier &#8211; <a href="http://www.gamasutra.com/gdcarchive/2002/rob_fermier.ppt">Creating a Data Driven Engine: Case Study: The Age Of Mythology</a><br />
Doug Church &#8211; <a href="http://chrishecker.com/images/6/6f/ObjSys.ppt">Object Systems</a><br />
Mick West &#8211; <a href="http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/">Refactoring Game Entities with Components</a><br />
<a href="http://gamearchitect.net/">Kyle Wilson</a> has a blog with a bunch of strong posts about engine design. Be sure to check out the <a href="http://www.gamearchitect.net/citydesk.html">old posts</a> as well.</p>
<p><strong>iPhone Engines</strong><br />
<a href="http://unity3d.com/">Unity 3D</a> &#8211; Commercial 3D engine. Combines powerful scripting with a visual editor to dramatically speed up the development process. Hundreds of games on the App Store. Well laid out component model.<br />
<a href="http://oolongengine.com/">Oolong Engine</a> &#8211; Open source 3D engine. Uses PowerVR POD for storing meshes and Bullet physics.<br />
<a href="http://sio2interactive.com/SIO2_Free_Open_Source_3D_Game_Engine_for_iPhone_and_iPod_Touch/SIO2_Free_Open_Source_3D_Game_Engine_for_iPhone_and_iPod_Touch.html">SIO2</a> &#8211; Open source 3D engine. Toolchain built around Blender and integrates with Bullet physics.<br />
<a href="http://cocos2d.org/">Cocos 2D</a> &#8211; Open source 2D engine. Well organized.<br />
<a href="http://www.torquepowered.com/products/torque-2d/iphone">Torque 2D</a> &#8211; Commercial 2D engine<br />
<a href="http://www.torquepowered.com/products/tge-iphone">Torque 3D</a> &#8211; Commercial 3D engine<br />
<a href="http://www.stonetrip.com/">Shiva 3D</a> &#8211; Commercial 3D engine. Windows only editor, but supports iPhone publishing</p>
<p><strong>Engines for other platforms</strong><br />
<a href="http://udn.epicgames.com/Three/UnrealScriptReference.html">Unreal</a> &#8211; One of the most successful game engines on the market. Worth reading through the documentation to pick up on design considerations. Separates out most game logic into a custom scripting language called UnrealScript.<br />
<a href="http://developer.valvesoftware.com/wiki/SDK_Docs">Source</a> &#8211; Valve&#8217;s engine for Half Life 2 and many mods. Extensive wiki documentation.<br />
<a href="http://www.idsoftware.com/business/techdownloads/">idTech 3</a> &#8211; Engine from Quake III Arena, now open sourced. A few years out of date, but shows a lot about client-server programming as well as insane performance optimizations. There are a <a href="http://element61.blogspot.com/2005/08/looking-at-quake-3-source-part-1.html">couple</a> <a href="http://www.fabiensanglard.net/quakeSource/index.php">people</a> who have gone through the source and give pointers on things to look at, which is immensely helpful .<br />
<a href="http://www.panda3d.org/">Panda3D</a> &#8211; Open source engine written in Python and C++. All game logic is written in Python. Does a good job of showing how to separate engine code from script.<br />
<a href="http://www.ogre3d.org/">OGRE</a> &#8211; Open source C++ engine in process of being ported to iPhone<br />
<a href="http://www.crystalspace3d.org/main/Main_Page">Crystal Space</a> &#8211; C++ open source engine</p>
<img src="http://feeds.feedburner.com/~r/kleinsch/~4/JvOZvC9XSno" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://kleinsch.com/2010/01/18/game-engine-design-iphone-game-engine-resources/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://kleinsch.com/2010/01/18/game-engine-design-iphone-game-engine-resources/</feedburner:origLink></item>
		<item>
		<title>Startup Engineers: Learning the Core</title>
		<link>http://feedproxy.google.com/~r/kleinsch/~3/1yJTuHZi-bg/</link>
		<comments>http://kleinsch.com/2010/01/03/startup-engineers-learning-the-core/#comments</comments>
		<pubDate>Sun, 03 Jan 2010 15:12:33 +0000</pubDate>
		<dc:creator>Nick Kleinschmidt</dc:creator>
				<category><![CDATA[Main]]></category>
		<category><![CDATA[employee]]></category>
		<category><![CDATA[engineer]]></category>
		<category><![CDATA[startup]]></category>

		<guid isPermaLink="false">http://kleinsch.com/?p=210</guid>
		<description><![CDATA[At any new job, there are a lot of things for engineers to learn. It&#8217;s easy to get distracted by platforms, languages, team characteristics, the industry, business models, etc. One area that gets frequently overlooked is learning your company&#8217;s core competency or technology. At every company (or department within a large company), there&#8217;s an area [...]]]></description>
			<content:encoded><![CDATA[<p>At any new job, there are a lot of things for engineers to learn. It&#8217;s easy to get distracted by platforms, languages, team characteristics, the industry, business models, etc. One area that gets frequently overlooked is learning your company&#8217;s core competency or technology. At every company (or department within a large company), there&#8217;s an area that&#8217;s their specialty. For Apple, it&#8217;s building intuitive products. For Oracle, it&#8217;s organizing huge amounts of data. While you can come out of a job and say that you grew your general software development skills, it&#8217;s better to do that <em>and</em> gain a new area of expertise.</p>
<p>Your company&#8217;s core strength may not be part of your job description. You may be working on back-end enterprise reporting for a company that prides itself on brilliant user interfaces or doing interface work for a company that specializes in data analysis. While you may not ever be directly working on the core competency, it&#8217;s still possible to learn enough to be useful later on. If it&#8217;s something that can be researched on your own, grab some books and do some reading. Talk to people who are working on it and get their opinions and ideas. Unless your company is highly secretive, you probably have source code access. Look into what tools are being used and read the source. You don&#8217;t necessary need to know it line by line, just enough that you understand the concepts involved and could participate in a discussion about pros and cons.</p>
<p>Obviously, if you&#8217;re working on web applications you should be very familiar with web programming. It&#8217;s going to be assumed in the future that you&#8217;re an expert in the language and platform on which you spent the most time. While it&#8217;s essential to learn these things, most companies&#8217; core competency is not knowledge of a platform or language. 37signals aren&#8217;t focused on Ruby on Rails, they design simple, clean products. ngmoco don&#8217;t pride themselves on knowing iPhone APIs better than anyone else, they&#8217;re good at making fun mobile games. While learning the platform is essential, it&#8217;s important not to confuse that with learning the company&#8217;s core competency.</p>
<p>Being familiar with your company&#8217;s core competency enables you to be part of the important discussions that go on every day. When you don&#8217;t understand the key concepts involved, you&#8217;ll have a hard time participating in conversations about changing the core product. When you have the knowledge and can offer suggestions, you&#8217;ll get involved more and will be seen as more valuable to the company. If a key project needs another person, you&#8217;ll be much more likely to get on it. A developer with key domain knowledge is also much more difficult to replace, which can benefit you financially and in terms of job security.</p>
<p>Unless you&#8217;re staying focused to one specific industry, these things are usually fairly unique. In the first two jobs I&#8217;ve had out of college, I&#8217;ve learned all about call platforms (the software that manages automated phone calls), machine learning, and ad servers. While some of these are more generally applicable than others, I&#8217;ve had all of them come up in conversations about unrelated topics. When you&#8217;re applying for your next job, every other applicant is also going to list being good at web programming. It&#8217;s the other interesting details that make your resume really stand out.</p>
<img src="http://feeds.feedburner.com/~r/kleinsch/~4/1yJTuHZi-bg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://kleinsch.com/2010/01/03/startup-engineers-learning-the-core/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://kleinsch.com/2010/01/03/startup-engineers-learning-the-core/</feedburner:origLink></item>
		<item>
		<title>For Startup Employees, Learning is Job One</title>
		<link>http://feedproxy.google.com/~r/kleinsch/~3/UCiHdPHZiAI/</link>
		<comments>http://kleinsch.com/2009/11/22/for-startup-employees-learning-is-job-one/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 00:43:44 +0000</pubDate>
		<dc:creator>Nick Kleinschmidt</dc:creator>
				<category><![CDATA[Main]]></category>
		<category><![CDATA[employee]]></category>
		<category><![CDATA[engineer]]></category>
		<category><![CDATA[startup]]></category>

		<guid isPermaLink="false">http://kleinsch.com/?p=154</guid>
		<description><![CDATA[If the job you're in isn't going to make you rich, it needs to be preparing you for the position that will. If you're in a learning stage, keep that in mind every day on your way to work.]]></description>
			<content:encoded><![CDATA[<p>Earlier this month, Mark Suster published what I consider to be one of the best startup blog posts of the year in his <a href="http://www.bothsidesofthetable.com/2009/11/04/is-it-time-for-you-to-earn-or-to-learn/">Earn or Learn</a> article. The first point in the article refreshed something that young, mid-stage startup employees (like myself) frequently forget: your engineer&#8217;s share of the options isn&#8217;t going to make you rich. It may be a nice bonus, but there&#8217;s almost no chance of retiring in the unlikely event of a liquidation.</p>
<p>The second point resonated even stronger. If the job you&#8217;re in isn&#8217;t going to make you rich, it needs to be preparing you for the position that will. If you&#8217;re in a learning stage, keep that in mind every day on your way to work. Since the article was talking about advice for whether or not to take a new job it also left out one possibility: move. If you&#8217;re holding a job with little possibility of earning or learning, it may be time for a change.</p>
<p>My next few posts will give some areas of concentration for startup employees trying to learn as much as possible from their experience.</p>
<img src="http://feeds.feedburner.com/~r/kleinsch/~4/UCiHdPHZiAI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://kleinsch.com/2009/11/22/for-startup-employees-learning-is-job-one/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://kleinsch.com/2009/11/22/for-startup-employees-learning-is-job-one/</feedburner:origLink></item>
		<item>
		<title>Wireshark ChmodBPF errors on Snow Leopard</title>
		<link>http://feedproxy.google.com/~r/kleinsch/~3/NSdaDUXoxMc/</link>
		<comments>http://kleinsch.com/2009/10/03/wireshark-chmodbpf-errors-on-snow-leopard/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 15:50:59 +0000</pubDate>
		<dc:creator>Nick Kleinschmidt</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[wireshark]]></category>

		<guid isPermaLink="false">http://kleinsch.com/?p=104</guid>
		<description><![CDATA[If you restart at this point, you'll get an error message that says "Insecure Startup Item disabled. - “/Library/StartupItems/ChmodBPF” has not been started because it does not have the proper security settings." Using information from an <a href="http://support.apple.com/kb/HT2413?viewlocale=en_US">Apple support article</a>, I realized you need to change the owner of the scripts for them to be run on startup. Run the command below and everything will work fine!]]></description>
			<content:encoded><![CDATA[<p>When I got Snow Leopard, I decided to do some house cleaning. I wiped the disk and reinstalled everything from scratch. I didn&#8217;t have any problems along the way until I went to install my favorite network protocol analyzer: Wireshark.</p>
<p>Installing is a simple matter of dragging the application into your Applications folder, but there&#8217;s also a startup item that sets some necessary permissions. To set that up, go into the Utilities folder on the Wireshark disk image, and drag the ChmodBPF folder onto the StartupItems shortcut. It&#8217;ll prompt you to authenticate and then copy. If you restart at this point, you&#8217;ll get an error message that says &#8220;Insecure Startup Item disabled. &#8211; “/Library/StartupItems/ChmodBPF” has not been started because it does not have the proper security settings.&#8221;</p>
<p>Using information from an <a href="http://support.apple.com/kb/HT2413?viewlocale=en_US">Apple support article</a>, I realized you need to change the owner of the scripts for them to be run on startup. Run the command below and everything will work fine!</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>StartupItems
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> root:wheel ChmodBPF</pre></div></div>

<p><strong><br />
Update (7/14/2010)</strong> &#8211; Make sure you restart your computer after running this command. The script only runs at startup, so just changing the permissions doesn&#8217;t do anything by itself. You have to restart for the script to run.</p>
<img src="http://feeds.feedburner.com/~r/kleinsch/~4/NSdaDUXoxMc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://kleinsch.com/2009/10/03/wireshark-chmodbpf-errors-on-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		<feedburner:origLink>http://kleinsch.com/2009/10/03/wireshark-chmodbpf-errors-on-snow-leopard/</feedburner:origLink></item>
		<item>
		<title>Git Workflow – Part 4: Remote Branches</title>
		<link>http://feedproxy.google.com/~r/kleinsch/~3/zetsJLBaylo/</link>
		<comments>http://kleinsch.com/2009/10/03/git-workflow-%e2%80%93-part-4-remote-branches/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 15:35:51 +0000</pubDate>
		<dc:creator>Nick Kleinschmidt</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://kleinsch.com/?p=136</guid>
		<description><![CDATA[The final piece of Git I'll be covering is using shared remote branches. This can be helpful if you have a team working on a development and a release branch, among other scenarios.]]></description>
			<content:encoded><![CDATA[<p>The final piece of Git I&#8217;ll be covering is using shared remote branches. This can be helpful if you have a team working on a development and a release branch, among other scenarios.</p>
<p>I&#8217;ll start by setting up a central repository and two working repositories based off it. I&#8217;ll be supplying an extra argument to the clone command to make things less confusing, this gives the name of the directory in which to check out the branch. For example, &#8220;git checkout first.git&#8221; (no argument) checks out into a directory called &#8220;first&#8221;. Using &#8220;git checkout first.git second&#8221; will check out into a directory called &#8220;second&#8221;.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:tmp nick$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> first.git <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">cd</span> first.git
Kleinschs-Macbook:first.git nick$ git <span style="color: #660033;">--bare</span> init <span style="color: #660033;">--shared</span>
Initialized empty shared Git repository <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>nick<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>first.git<span style="color: #000000; font-weight: bold;">/</span>
Kleinschs-Macbook:first.git nick$ <span style="color: #7a0874; font-weight: bold;">cd</span> ..
Kleinschs-Macbook:tmp nick$ git clone first.git second
Initialized empty Git repository <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>nick<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>second<span style="color: #000000; font-weight: bold;">/</span>.git<span style="color: #000000; font-weight: bold;">/</span>
warning: You appear to have cloned an empty repository.
Kleinschs-Macbook:tmp nick$ <span style="color: #7a0874; font-weight: bold;">cd</span> second
Kleinschs-Macbook:second nick$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'First file contents'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> file1
Kleinschs-Macbook:second nick$ git add file1
Kleinschs-Macbook:second nick$ git commit <span style="color: #660033;">-am</span><span style="color: #ff0000;">'added first file'</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>master <span style="color: #7a0874; font-weight: bold;">&#40;</span>root-commit<span style="color: #7a0874; font-weight: bold;">&#41;</span> 19b39e3<span style="color: #7a0874; font-weight: bold;">&#93;</span> added first <span style="color: #c20cb9; font-weight: bold;">file</span>
 <span style="color: #000000;">1</span> files changed, <span style="color: #000000;">1</span> insertions<span style="color: #7a0874; font-weight: bold;">&#40;</span>+<span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">0</span> deletions<span style="color: #7a0874; font-weight: bold;">&#40;</span>-<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 create mode <span style="color: #000000;">100644</span> file1
Kleinschs-Macbook:second nick$ git push origin master
Counting objects: <span style="color: #000000;">3</span>, done.
Writing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">243</span> bytes, done.
Total <span style="color: #000000;">3</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Unpacking objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
To <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>nick<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>first.git
 <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>new branch<span style="color: #7a0874; font-weight: bold;">&#93;</span>      master -<span style="color: #000000; font-weight: bold;">&gt;</span> master
Kleinschs-Macbook:second nick$ <span style="color: #7a0874; font-weight: bold;">cd</span> ..
Kleinschs-Macbook:tmp nick$ git clone first.git third
Initialized empty Git repository <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>nick<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>third<span style="color: #000000; font-weight: bold;">/</span>.git<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Now that I have two working repositories, I&#8217;ll go create a release branch on the second repository.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:tmp nick$ <span style="color: #7a0874; font-weight: bold;">cd</span> second
Kleinschs-Macbook:second nick$ git checkout <span style="color: #660033;">-b</span> release
Switched to a new branch <span style="color: #ff0000;">'release'</span>
Kleinschs-Macbook:second nick$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'Second file contents'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> file2
Kleinschs-Macbook:second nick$ git add file2
Kleinschs-Macbook:second nick$ git commit <span style="color: #660033;">-am</span><span style="color: #ff0000;">'added file2'</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>release 48a00ee<span style="color: #7a0874; font-weight: bold;">&#93;</span> added file2
 <span style="color: #000000;">1</span> files changed, <span style="color: #000000;">1</span> insertions<span style="color: #7a0874; font-weight: bold;">&#40;</span>+<span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">0</span> deletions<span style="color: #7a0874; font-weight: bold;">&#40;</span>-<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 create mode <span style="color: #000000;">100644</span> file2</pre></div></div>

<p>Since I have this release branch, I&#8217;d like to expose it to the rest of the team so that everyone is looking at the same version. Adding a branch is as simple as doing a push with the name of the new branch. In this example, I&#8217;m telling Git to push to a remote branch that doesn&#8217;t exist, so it creates it.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:second nick$ git push origin release:release
Counting objects: <span style="color: #000000;">4</span>, done.
Delta compression using up to <span style="color: #000000;">2</span> threads.
Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
Writing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">292</span> bytes, done.
Total <span style="color: #000000;">3</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Unpacking objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
To <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>nick<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>first.git
 <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>new branch<span style="color: #7a0874; font-weight: bold;">&#93;</span>      release -<span style="color: #000000; font-weight: bold;">&gt;</span> release</pre></div></div>

<p>Listing the branches will show that the branch was created on the remote repository as well.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:second nick$ git branch <span style="color: #660033;">-a</span>
  master
<span style="color: #000000; font-weight: bold;">*</span> release
  remotes<span style="color: #000000; font-weight: bold;">/</span>origin<span style="color: #000000; font-weight: bold;">/</span>master
  remotes<span style="color: #000000; font-weight: bold;">/</span>origin<span style="color: #000000; font-weight: bold;">/</span>release</pre></div></div>

<p>Now let&#8217;s go over to the third repository and make sure we can access the release branch. First we do a pull to make sure we have the latest data from the remote server.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:second nick$ <span style="color: #7a0874; font-weight: bold;">cd</span> ..<span style="color: #000000; font-weight: bold;">/</span>third<span style="color: #000000; font-weight: bold;">/</span>
Kleinschs-Macbook:third nick$ git pull
remote: Counting objects: <span style="color: #000000;">4</span>, done.
remote: Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
remote: Total <span style="color: #000000;">3</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Unpacking objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
From <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>nick<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>first
 <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>new branch<span style="color: #7a0874; font-weight: bold;">&#93;</span>      release    -<span style="color: #000000; font-weight: bold;">&gt;</span> origin<span style="color: #000000; font-weight: bold;">/</span>release
Already up-to-date.
Kleinschs-Macbook:third nick$ <span style="color: #c20cb9; font-weight: bold;">ls</span>
file1</pre></div></div>

<p>We&#8217;re still not seeing the second file that was checked in on the release branch. This is because we&#8217;re still on the master branch at this point. In order to access the remote release branch, we need to create a local tracking branch for our changes. A tracking branch is a local branch that&#8217;s set up with a remote branch so that pushes and pulls go to the corresponding remote branch. In order to set up a tracking branch, just supply the &#8220;&#8211;track&#8221; flag to the branch command.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:third nick$ git branch <span style="color: #660033;">--track</span> release origin<span style="color: #000000; font-weight: bold;">/</span>release
Branch release <span style="color: #000000; font-weight: bold;">set</span> up to track remote branch release from origin.
Kleinschs-Macbook:third nick$ git checkout release
Switched to branch <span style="color: #ff0000;">'release'</span>
Kleinschs-Macbook:third nick$ <span style="color: #c20cb9; font-weight: bold;">ls</span>
file1	file2</pre></div></div>

<p>As you can see, we received the second file that was checked in on the release branch, so we should be ready to go. There&#8217;s one more thing I&#8217;d like to clear up. What if you have an existing branch that you&#8217;d like to have track a remote branch? The easiest way to do this is to edit your Git config file. Outputting the config from the the third repository will make this a little more clear.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:third nick$ <span style="color: #c20cb9; font-weight: bold;">cat</span> .git<span style="color: #000000; font-weight: bold;">/</span>config
<span style="color: #7a0874; font-weight: bold;">&#91;</span>core<span style="color: #7a0874; font-weight: bold;">&#93;</span>
	repositoryformatversion = <span style="color: #000000;">0</span>
	filemode = <span style="color: #c20cb9; font-weight: bold;">true</span>
	bare = <span style="color: #c20cb9; font-weight: bold;">false</span>
	logallrefupdates = <span style="color: #c20cb9; font-weight: bold;">true</span>
	ignorecase = <span style="color: #c20cb9; font-weight: bold;">true</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>remote <span style="color: #ff0000;">&quot;origin&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
	fetch = +refs<span style="color: #000000; font-weight: bold;">/</span>heads<span style="color: #000000; font-weight: bold;">/*</span>:refs<span style="color: #000000; font-weight: bold;">/</span>remotes<span style="color: #000000; font-weight: bold;">/</span>origin<span style="color: #000000; font-weight: bold;">/*</span>
	url = <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>nick<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>first.git
<span style="color: #7a0874; font-weight: bold;">&#91;</span>branch <span style="color: #ff0000;">&quot;master&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
	remote = origin
	merge = refs<span style="color: #000000; font-weight: bold;">/</span>heads<span style="color: #000000; font-weight: bold;">/</span>master
<span style="color: #7a0874; font-weight: bold;">&#91;</span>branch <span style="color: #ff0000;">&quot;release&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
	remote = origin
	merge = refs<span style="color: #000000; font-weight: bold;">/</span>heads<span style="color: #000000; font-weight: bold;">/</span>release</pre></div></div>

<p>The section for branch &#8220;release&#8221; has the relevant information. If you wanted to set up the second repository so its release branch was tracking the remote release branch, you just need to add these three lines to second/.git/config.</p>
<p>This concludes my series on Git. There&#8217;s a lot more to it than these four articles describe, but this should be a good jumping off point.</p>
<img src="http://feeds.feedburner.com/~r/kleinsch/~4/zetsJLBaylo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://kleinsch.com/2009/10/03/git-workflow-%e2%80%93-part-4-remote-branches/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://kleinsch.com/2009/10/03/git-workflow-%e2%80%93-part-4-remote-branches/</feedburner:origLink></item>
		<item>
		<title>Git Workflow – Part 3: Remote Operations</title>
		<link>http://feedproxy.google.com/~r/kleinsch/~3/sBDhyk1c9qE/</link>
		<comments>http://kleinsch.com/2009/09/30/git-workflow-part-3-remote-operations/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 12:16:01 +0000</pubDate>
		<dc:creator>Nick Kleinschmidt</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://kleinsch.com/?p=115</guid>
		<description><![CDATA[Using Git on a single machine may have its uses, but most people using Git are using it for its remote operations. Git functions in a variety of ways, I'll be focusing on a central repository in this article. For more complicated workflows, see the <a href="http://book.git-scm.com/">Git Book</a>.

The first thing to do is to set up a central repository.]]></description>
			<content:encoded><![CDATA[<p>Using Git on a single machine may have its uses, but most people using Git are using it for its remote operations. Git functions in a variety of ways, I&#8217;ll be focusing on a central repository in this article. For more complicated workflows, see the <a href="http://book.git-scm.com/">Git Book</a>.</p>
<p>The first thing to do is to set up a central repository. You can make it a normal Git repository like any other, but a few things will be easier if you make it what&#8217;s called a bare repository. This means that there&#8217;s no working copy, it just stores revisions. Adding the flag &#8220;&#8211;bare&#8221; to the init command sets it up as bare. I also like to add the &#8220;&#8211;shared&#8221; flag if you&#8217;re going to be sharing it across multiple users, this helps fix permissions. Look it up if you&#8217;re very curious. It also helps to name the shared repository ending in &#8220;.git&#8221;. If it&#8217;s set up that way, when people clone it, Git will lose the extension and just take the name. We&#8217;ll see that below.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:tmp nick$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> first.git <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">cd</span> first.git
Kleinschs-Macbook:first.git nick$ git <span style="color: #660033;">--bare</span> init <span style="color: #660033;">--shared</span>
Initialized empty shared Git repository <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>nick<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>first.git<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Now that the bare repository is set up, we need to get something into it. There are two ways to connect to a remote repository: cloning and adding to an existing repository. I&#8217;ll add it to an existing repository first. This can be handy if you want to import existing files into a new repository.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first.git nick$ <span style="color: #7a0874; font-weight: bold;">cd</span> ..
Kleinschs-Macbook:tmp nick$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> second.git <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">cd</span> second.git
Kleinschs-Macbook:second.git nick$ git init
Initialized empty Git repository <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>nick<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>second.git<span style="color: #000000; font-weight: bold;">/</span>.git<span style="color: #000000; font-weight: bold;">/</span>
Kleinschs-Macbook:second.git nick$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'First file contents'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> file1
Kleinschs-Macbook:second.git nick$ git add file1
Kleinschs-Macbook:second.git nick$ git commit <span style="color: #660033;">-am</span><span style="color: #ff0000;">'Added file1'</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>master <span style="color: #7a0874; font-weight: bold;">&#40;</span>root-commit<span style="color: #7a0874; font-weight: bold;">&#41;</span> 1a603a8<span style="color: #7a0874; font-weight: bold;">&#93;</span> Added file1
 <span style="color: #000000;">1</span> files changed, <span style="color: #000000;">1</span> insertions<span style="color: #7a0874; font-weight: bold;">&#40;</span>+<span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">0</span> deletions<span style="color: #7a0874; font-weight: bold;">&#40;</span>-<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 create mode <span style="color: #000000;">100644</span> file1</pre></div></div>

<p>Up to this point everything is standard. In order to commit changes into the central repository, we need to add the server and push the changes. The &#8220;remote&#8221; command takes care of remote repository setup in Git. The &#8220;remote add&#8221; adds a remote location, with the first parameter being the name and second being the location. In this example I&#8217;m using a local repository, but you could also do it via SSH, which I&#8217;ll show later. After you&#8217;ve added the remote location, use the &#8220;push&#8221; command to commit your changes to the remote branch. The first parameter is the remote location (using the name you just specified in the &#8220;remote add&#8221; command), second parameter is the remote branch for the commit. This pushes your current branch to the specified remote branch. For example, if I give the command &#8220;git push origin master&#8221;, it pushes my current branch to the master branch of the remote repository named origin. If you don&#8217;t want to push your current branch, you can specify which local branch to push in the command like this: &#8220;git push origin local-branch:remote-branch&#8221;. This would commit my branch named local-branch to the branch named remote-branch on origin.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:second.git nick$ git remote add origin ..<span style="color: #000000; font-weight: bold;">/</span>first.git
Kleinschs-Macbook:second.git nick$ git push origin master
Counting objects: <span style="color: #000000;">3</span>, done.
Writing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">239</span> bytes, done.
Total <span style="color: #000000;">3</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Unpacking objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
To ..<span style="color: #000000; font-weight: bold;">/</span>first.git
 <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>new branch<span style="color: #7a0874; font-weight: bold;">&#93;</span>      master -<span style="color: #000000; font-weight: bold;">&gt;</span> master</pre></div></div>

<p>Now that we&#8217;ve got an initial commit in, let&#8217;s try the second way of connecting to a remote repository. The command &#8220;clone&#8221; copies everything from an existing repository and sets it up as a new repository. Again, in this example I&#8217;m using a local directory as the argument, but it can take other arguments including SSH.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:second.git nick$ <span style="color: #7a0874; font-weight: bold;">cd</span> ..
Kleinschs-Macbook:tmp nick$ git clone first.git
Initialized empty Git repository <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>nick<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>first<span style="color: #000000; font-weight: bold;">/</span>.git<span style="color: #000000; font-weight: bold;">/</span>
Kleinschs-Macbook:tmp nick$ <span style="color: #7a0874; font-weight: bold;">cd</span> first
Kleinschs-Macbook:first nick$ <span style="color: #c20cb9; font-weight: bold;">ls</span>
file1</pre></div></div>

<p>Notice that we cloned &#8220;first.git&#8221;, so our clone is just named &#8220;first&#8221;. Let&#8217;s try adding a file through the newly cloned branch.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'Second file contents'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> file2
Kleinschs-Macbook:first nick$ git add file2
Kleinschs-Macbook:first nick$ git commit <span style="color: #660033;">-am</span><span style="color: #ff0000;">'added second file'</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>master 478a452<span style="color: #7a0874; font-weight: bold;">&#93;</span> added second <span style="color: #c20cb9; font-weight: bold;">file</span>
 <span style="color: #000000;">1</span> files changed, <span style="color: #000000;">1</span> insertions<span style="color: #7a0874; font-weight: bold;">&#40;</span>+<span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">0</span> deletions<span style="color: #7a0874; font-weight: bold;">&#40;</span>-<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 create mode <span style="color: #000000;">100644</span> file2
Kleinschs-Macbook:first nick$ git status
<span style="color: #666666; font-style: italic;"># On branch master</span>
<span style="color: #666666; font-style: italic;"># Your branch is ahead of 'origin/master' by 1 commit.</span>
<span style="color: #666666; font-style: italic;">#</span>
nothing to commit <span style="color: #7a0874; font-weight: bold;">&#40;</span>working directory clean<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>If you compared the .git/config files between second.git and first (the cloned repository), you&#8217;ll notice that in the cloned repository, there&#8217;s an extra line about our master branch:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>branch <span style="color: #ff0000;">&quot;master&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
	remote = origin
	merge = refs<span style="color: #000000; font-weight: bold;">/</span>heads<span style="color: #000000; font-weight: bold;">/</span>master</pre></div></div>

<p>This sets up our local branch to link to origin&#8217;s master branch. This means that when we do remote operations from our master branch, we don&#8217;t have to specify the remote location or branch. This means that in order to push our changes, we just have to do a &#8220;git push&#8221;.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ git push
Counting objects: <span style="color: #000000;">4</span>, done.
Delta compression using up to <span style="color: #000000;">2</span> threads.
Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
Writing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">300</span> bytes, done.
Total <span style="color: #000000;">3</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Unpacking objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
To <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>nick<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>first.git
   1a603a8..478a452  master -<span style="color: #000000; font-weight: bold;">&gt;</span> master</pre></div></div>

<p>Now that we&#8217;re pushing changes out frequently, we need to be able to download those changes from the central repository. The &#8220;fetch&#8221; command gets all revisions from a remote repository.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ <span style="color: #7a0874; font-weight: bold;">cd</span> ..<span style="color: #000000; font-weight: bold;">/</span>second.git
Kleinschs-Macbook:second.git nick$ git fetch origin
remote: Counting objects: <span style="color: #000000;">4</span>, done.
remote: Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
remote: Total <span style="color: #000000;">3</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Unpacking objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
From ..<span style="color: #000000; font-weight: bold;">/</span>first
   1a603a8..478a452  master     -<span style="color: #000000; font-weight: bold;">&gt;</span> origin<span style="color: #000000; font-weight: bold;">/</span>master</pre></div></div>

<p>You&#8217;ll see it downloaded them and refers to them using the notation &#8220;remote-location/remote-branch-name&#8221;. The fetch command doesn&#8217;t move the changes into your existing working copy, you&#8217;ll need to take care of this yourself. In order to pull the changes into your current local branch, you do a normal merge.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:second.git nick$ git merge origin<span style="color: #000000; font-weight: bold;">/</span>master
Updating 1a603a8..478a452
Fast forward
 file2 <span style="color: #000000; font-weight: bold;">|</span>    <span style="color: #000000;">1</span> +
 <span style="color: #000000;">1</span> files changed, <span style="color: #000000;">1</span> insertions<span style="color: #7a0874; font-weight: bold;">&#40;</span>+<span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">0</span> deletions<span style="color: #7a0874; font-weight: bold;">&#40;</span>-<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 create mode <span style="color: #000000;">100644</span> file2</pre></div></div>

<p>Since the process of fetching and merging is a frequent one, there&#8217;s a command that combines them: &#8220;pull&#8221;. Doing a pull runs a fetch and merges the specified remote branch into your current local one.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:second.git nick$ git pull origin master
From ..<span style="color: #000000; font-weight: bold;">/</span>first
 <span style="color: #000000; font-weight: bold;">*</span> branch            master     -<span style="color: #000000; font-weight: bold;">&gt;</span> FETCH_HEAD
Already up-to-date.</pre></div></div>

<p>Pulling and pushing is fairly simple, but there&#8217;s one common error I&#8217;ve run into that I&#8217;ll illustrate here. I&#8217;m going to push a commit from my second repository, then try to push a commit from my cloned repository.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:second.git nick$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'Third file contents'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> file3
Kleinschs-Macbook:second.git nick$ git add file3
Kleinschs-Macbook:second.git nick$ git commit <span style="color: #660033;">-am</span><span style="color: #ff0000;">'added third file'</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>master c114c2b<span style="color: #7a0874; font-weight: bold;">&#93;</span> added third <span style="color: #c20cb9; font-weight: bold;">file</span>
 <span style="color: #000000;">1</span> files changed, <span style="color: #000000;">1</span> insertions<span style="color: #7a0874; font-weight: bold;">&#40;</span>+<span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">0</span> deletions<span style="color: #7a0874; font-weight: bold;">&#40;</span>-<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 create mode <span style="color: #000000;">100644</span> file3
Kleinschs-Macbook:second.git nick$ git push
Counting objects: <span style="color: #000000;">4</span>, done.
Delta compression using up to <span style="color: #000000;">2</span> threads.
Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
Writing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">324</span> bytes, done.
Total <span style="color: #000000;">3</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Unpacking objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
To ..<span style="color: #000000; font-weight: bold;">/</span>first.git
   478a452..c114c2b  master -<span style="color: #000000; font-weight: bold;">&gt;</span> master
&nbsp;
Kleinschs-Macbook:second.git nick$ <span style="color: #7a0874; font-weight: bold;">cd</span> ..<span style="color: #000000; font-weight: bold;">/</span>first
Kleinschs-Macbook:first nick$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'Fourth file contents'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> file4
Kleinschs-Macbook:first nick$ git add file4
Kleinschs-Macbook:first nick$ git commit <span style="color: #660033;">-am</span><span style="color: #ff0000;">'added fourth file'</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>master 17411ef<span style="color: #7a0874; font-weight: bold;">&#93;</span> added fourth <span style="color: #c20cb9; font-weight: bold;">file</span>
 <span style="color: #000000;">1</span> files changed, <span style="color: #000000;">1</span> insertions<span style="color: #7a0874; font-weight: bold;">&#40;</span>+<span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">0</span> deletions<span style="color: #7a0874; font-weight: bold;">&#40;</span>-<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 create mode <span style="color: #000000;">100644</span> file4
Kleinschs-Macbook:first nick$ git push
To <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>nick<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>first.git
 <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>rejected<span style="color: #7a0874; font-weight: bold;">&#93;</span>        master -<span style="color: #000000; font-weight: bold;">&gt;</span> master <span style="color: #7a0874; font-weight: bold;">&#40;</span>non-fast forward<span style="color: #7a0874; font-weight: bold;">&#41;</span>
error: failed to push some refs to <span style="color: #ff0000;">'/Users/nick/tmp/first.git'</span>
To prevent you from losing <span style="color: #7a0874; font-weight: bold;">history</span>, non-fast-forward updates were rejected.
Merge the remote changes before pushing again.
See <span style="color: #ff0000;">'non-fast forward'</span> section of <span style="color: #ff0000;">'git push --help'</span> <span style="color: #000000; font-weight: bold;">for</span> details.</pre></div></div>

<p>When I tried to do the second push, it was rejected. This is because Git requires that push operations result in a fast forward merge. If push operations didn&#8217;t have to be fast forward there could be unresolvable conflicts on the central server, which would leave things in a bad state for other users. For this reason, you need to take care of conflicts locally before doing a push. The simple fix for this is to do a pull and make sure you&#8217;re up to date before trying to do a push. If your changes really have to go in, there are ways to override the fast forward requirement, see the Git book for advanced options.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ git pull
remote: Counting objects: <span style="color: #000000;">4</span>, done.
remote: Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
remote: Total <span style="color: #000000;">3</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Unpacking objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
From <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>nick<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>first
   478a452..c114c2b  master     -<span style="color: #000000; font-weight: bold;">&gt;</span> origin<span style="color: #000000; font-weight: bold;">/</span>master
Merge made by recursive.
 file3 <span style="color: #000000; font-weight: bold;">|</span>    <span style="color: #000000;">1</span> +
 <span style="color: #000000;">1</span> files changed, <span style="color: #000000;">1</span> insertions<span style="color: #7a0874; font-weight: bold;">&#40;</span>+<span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">0</span> deletions<span style="color: #7a0874; font-weight: bold;">&#40;</span>-<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 create mode <span style="color: #000000;">100644</span> file3
Kleinschs-Macbook:first nick$ git push
Counting objects: <span style="color: #000000;">7</span>, done.
Delta compression using up to <span style="color: #000000;">2</span> threads.
Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">4</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
Writing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">533</span> bytes, done.
Total <span style="color: #000000;">5</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Unpacking objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
To <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>nick<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>first.git
   c114c2b..5890924  master -<span style="color: #000000; font-weight: bold;">&gt;</span> master</pre></div></div>

<p>Now let&#8217;s go back over to the second repository to make sure our changes went through correctly.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ <span style="color: #7a0874; font-weight: bold;">cd</span> ..<span style="color: #000000; font-weight: bold;">/</span>second.git
Kleinschs-Macbook:second.git nick$ git pull origin master
remote: Counting objects: <span style="color: #000000;">7</span>, done.
remote: Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">4</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
remote: Total <span style="color: #000000;">5</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Unpacking objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
From ..<span style="color: #000000; font-weight: bold;">/</span>first
 <span style="color: #000000; font-weight: bold;">*</span> branch            master     -<span style="color: #000000; font-weight: bold;">&gt;</span> FETCH_HEAD
Updating c114c2b..5890924
Fast forward
 file4 <span style="color: #000000; font-weight: bold;">|</span>    <span style="color: #000000;">1</span> +
 <span style="color: #000000;">1</span> files changed, <span style="color: #000000;">1</span> insertions<span style="color: #7a0874; font-weight: bold;">&#40;</span>+<span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">0</span> deletions<span style="color: #7a0874; font-weight: bold;">&#40;</span>-<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 create mode <span style="color: #000000;">100644</span> file4
Kleinschs-Macbook:second.git nick$ <span style="color: #c20cb9; font-weight: bold;">ls</span>
file1	file2	file3	file4</pre></div></div>

<p>Everything looks good! I spoke above about setting up repositories over SSH. You&#8217;ll need to have a valid account on the machine to connect to a Git repository. It&#8217;s usually helpful to set up a public/private key so you don&#8217;t have to specify the password every time. There are other way to connect, but they&#8217;re a bit more involved. Google and the Git Book are your friend here (start by looking up Gitosis). Here&#8217;s an example of the connect string to use with SSH.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:second.git nick$ git clone <span style="color: #c20cb9; font-weight: bold;">ssh</span>:<span style="color: #000000; font-weight: bold;">//</span>nick<span style="color: #000000; font-weight: bold;">@</span>kleinsch.com<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>git<span style="color: #000000; font-weight: bold;">/</span>kleinsch.com.git<span style="color: #000000; font-weight: bold;">/</span>
Initialized empty Git repository <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>nick<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>second.git<span style="color: #000000; font-weight: bold;">/</span>kleinsch.com<span style="color: #000000; font-weight: bold;">/</span>.git<span style="color: #000000; font-weight: bold;">/</span>
remote: Counting objects: <span style="color: #000000;">2181</span>, done.
...</pre></div></div>

<p>I&#8217;ve made one mistake with SSH connect strings a couple of times now: this is <em>not</em> the same as the connect string for SCP. There&#8217;s no colon between the server and the path, unless you&#8217;re specifying a port. If you put one, you&#8217;ll just get a confusing error message, shown below.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:second.git nick$ git clone <span style="color: #c20cb9; font-weight: bold;">ssh</span>:<span style="color: #000000; font-weight: bold;">//</span>nick<span style="color: #000000; font-weight: bold;">@</span>kleinsch.com:<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>git<span style="color: #000000; font-weight: bold;">/</span>kleinsch.com.git<span style="color: #000000; font-weight: bold;">/</span>
Initialized empty Git repository <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>nick<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>second.git<span style="color: #000000; font-weight: bold;">/</span>kleinsch.com<span style="color: #000000; font-weight: bold;">/</span>.git<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">ssh</span>: Could not resolve <span style="color: #c20cb9; font-weight: bold;">hostname</span> kleinsch.com:: nodename nor servname provided, or not known
fatal: The remote end hung up unexpectedly</pre></div></div>

<p>That covers the basics of remote operations. I&#8217;ll be doing one more post about Git focusing on remote branches.</p>
<img src="http://feeds.feedburner.com/~r/kleinsch/~4/sBDhyk1c9qE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://kleinsch.com/2009/09/30/git-workflow-part-3-remote-operations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://kleinsch.com/2009/09/30/git-workflow-part-3-remote-operations/</feedburner:origLink></item>
		<item>
		<title>Git Workflow – Part 2: Branches</title>
		<link>http://feedproxy.google.com/~r/kleinsch/~3/mfl7Qq-jbyQ/</link>
		<comments>http://kleinsch.com/2009/08/26/git-workflow-part-2-branches/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 23:28:31 +0000</pubDate>
		<dc:creator>Nick Kleinschmidt</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://kleinsch.com/?p=59</guid>
		<description><![CDATA[The command 'branch' with no arguments will tell you which branches exist and put an asterisk next to the branch on which you're currently working. If you pass in a name, Git will create a branch with that name.]]></description>
			<content:encoded><![CDATA[<p>In the first tutorial, I showed how to set up a Git repository and commit basic changes. You could get a lot done using only those commands, but you&#8217;d be missing out on most of the benefits of Git. Most of that could be done in SVN or CVS fairly easily. In this tutorial, I&#8217;ll go through setting up branches and merging changes, one of Git&#8217;s main strengths. Git was built from the ground up for frequent branching. In other version control systems, you may use branches for releases or major events, but in Git your day to day workflow revolves around branches.</p>
<p>If you don&#8217;t want to go back through the first post, the following commands will get you in sync with what I set up in the first post.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> first <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">cd</span> first
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'firstEdit'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> file1
git init
git add file1
git commit <span style="color: #660033;">-m</span><span style="color: #ff0000;">'First commit'</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'secondEdit'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> file1
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'anotherFile'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> file2
git add file2
git commit <span style="color: #660033;">-am</span><span style="color: #ff0000;">'Made a second commit!'</span></pre></div></div>

<p>Branches have been a useful tool in version control for quite some time. They allow multiple versions of the same project to be actively developed. One of the most common use cases for branches is bug fixing. Let&#8217;s say you have a project that&#8217;s been released and you&#8217;re working on new features. Maybe you&#8217;ve committed a bunch of files but they&#8217;re not ready to go out to production. A user finds a showstopping bug that needs to be fixed immediately. Some people would pull the code from the production release, hack together a patch, and push it out. With branches, you can get the production branch, fix the bug, check in the changes, then switch back to your development branch and merge the changes. This tracks your changes so if you have to fix another production bug, nobody has to remember what went out in the last patch.</p>
<p>The command &#8216;branch&#8217; with no arguments will tell you which branches exist and put an asterisk next to the branch on which you&#8217;re currently working. If you pass in a name, Git will create a branch with that name.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ git branch
<span style="color: #000000; font-weight: bold;">*</span> master
Kleinschs-Macbook:first nick$ git branch development
Kleinschs-Macbook:first nick$ git branch
  development
<span style="color: #000000; font-weight: bold;">*</span> master</pre></div></div>

<p>The &#8216;checkout&#8217; command switches to another branch. One shortcut you can take is the &#8216;-b&#8217; flag to &#8216;checkout&#8217; which creates the branch and checks it out.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ git checkout development
Switched to branch <span style="color: #ff0000;">'development'</span>
Kleinschs-Macbook:first nick$ git branch
<span style="color: #000000; font-weight: bold;">*</span> development
  master
Kleinschs-Macbook:first nick$ git checkout <span style="color: #660033;">-b</span> my-dev-branch
Switched to a new branch <span style="color: #ff0000;">'my-dev-branch'</span>
Kleinschs-Macbook:first nick$ git branch
  development
  master
<span style="color: #000000; font-weight: bold;">*</span> my-dev-branch</pre></div></div>

<p>The command &#8216;gitk&#8217; brings up a window that shows the state of your branches graphically. By default, it hides branches not related to the current branch. The flag &#8216;&#8211;all&#8217; is useful to show all branches. This is useful in figuring out complicated branching and merging scenarios. The most useful part of the display is the top left corner, which shows your branches in order of commits. More recent commits are at the top. Doing this on my project brings up this.</p>
<p><img src="http://kleinsch.com/wp-content/uploads/2009/08/Branch-Merge-1.png" alt="Branch-Merge-1" title="Branch-Merge-1" width="355" height="39" class="alignnone size-full wp-image-78" /></p>
<p>All of our changes are in the same place, so the branches show up on the same commit. Let&#8217;s make some changes.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'secondEdit\n\nadded a line'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> file1</pre></div></div>

<p>At this point if you change branches, your uncommitted changes will follow. Each modified file will show up with an &#8216;M&#8217; next to it when you issue the checkout command.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ git checkout development
M	file1
Switched to branch <span style="color: #ff0000;">'development'</span>
Kleinschs-Macbook:first nick$ <span style="color: #c20cb9; font-weight: bold;">cat</span> file1
secondEdit
&nbsp;
added a line</pre></div></div>

<p>This seems a little strange, but can actually come in handy. Let&#8217;s say you&#8217;re working on something and it turns into a bigger project than you thought. You may want to work on that on a branch instead. In that case you can checkout onto a new branch, commit your changes, and keep working.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ git checkout <span style="color: #660033;">-b</span> testing-theory
M	file1
Switched to a new branch <span style="color: #ff0000;">'testing-theory'</span>
Kleinschs-Macbook:first nick$ git commit <span style="color: #660033;">-am</span><span style="color: #ff0000;">'first commit while testing something'</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>testing-theory 42a287a<span style="color: #7a0874; font-weight: bold;">&#93;</span> first commit <span style="color: #000000; font-weight: bold;">while</span> testing something
 <span style="color: #000000;">1</span> files changed, <span style="color: #000000;">2</span> insertions<span style="color: #7a0874; font-weight: bold;">&#40;</span>+<span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">0</span> deletions<span style="color: #7a0874; font-weight: bold;">&#40;</span>-<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Kleinschs-Macbook:first nick$ gitk</pre></div></div>

<p><img src="http://kleinsch.com/wp-content/uploads/2009/08/Branch-Merge-2.png" alt="Branch-Merge-2" title="Branch-Merge-2" width="353" height="49" class="alignnone size-full wp-image-79" /></p>
<p>This allows you to take advantage of version control for the things you&#8217;re working on that aren&#8217;t ready to be shared with other team members. You can work on this test branch as long as you want. Let&#8217;s say at the same time, you have to fix a bug on the production release, which for this project will be the master branch. First, checkout the master branch.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ git checkout master
Switched to branch <span style="color: #ff0000;">'master'</span></pre></div></div>

<p>Let&#8217;s first create a branch for fixing this bug. It&#8217;s quick and easy, and we can track our changes. Then we can make whatever changes are necessary.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ git checkout <span style="color: #660033;">-b</span> fixing-bug
Switched to a new branch <span style="color: #ff0000;">'fixing-bug'</span>
Kleinschs-Macbook:first nick$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'secondEdit - add to first line'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> file1
Kleinschs-Macbook:first nick$ git commit <span style="color: #660033;">-am</span><span style="color: #ff0000;">'fixed a bug in file1'</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>fixing-bug 645e620<span style="color: #7a0874; font-weight: bold;">&#93;</span> fixed a bug <span style="color: #000000; font-weight: bold;">in</span> file1
 <span style="color: #000000;">1</span> files changed, <span style="color: #000000;">1</span> insertions<span style="color: #7a0874; font-weight: bold;">&#40;</span>+<span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">1</span> deletions<span style="color: #7a0874; font-weight: bold;">&#40;</span>-<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Kleinschs-Macbook:first nick$ gitk <span style="color: #660033;">--all</span></pre></div></div>

<p><img src="http://kleinsch.com/wp-content/uploads/2009/08/Branch-Merge-3.png" alt="Branch-Merge-3" title="Branch-Merge-3" width="352" height="56" class="alignnone size-full wp-image-80" /></p>
<p>Now that we&#8217;ve fixed the bug, we&#8217;ll roll it out to production. Let&#8217;s merge the bug fix into the master branch. For this, we use the command &#8216;merge&#8217;. You must checkout the branch you&#8217;re merging to, then supply the branch you&#8217;re merging from as the argument to the merge command.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ git checkout master
Switched to branch <span style="color: #ff0000;">'master'</span>
Kleinschs-Macbook:first nick$ git merge fixing-bug
Updating 941bde0..645e620
Fast forward
 file1 <span style="color: #000000; font-weight: bold;">|</span>    <span style="color: #000000;">2</span> +-
 <span style="color: #000000;">1</span> files changed, <span style="color: #000000;">1</span> insertions<span style="color: #7a0874; font-weight: bold;">&#40;</span>+<span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">1</span> deletions<span style="color: #7a0874; font-weight: bold;">&#40;</span>-<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Kleinschs-Macbook:first nick$ gitk <span style="color: #660033;">--all</span></pre></div></div>

<p><img src="http://kleinsch.com/wp-content/uploads/2009/08/Branch-Merge-4.png" alt="Branch-Merge-4" title="Branch-Merge-4" width="306" height="64" class="alignnone size-full wp-image-81" /></p>
<p>As you can see, we merged the changes into our master branch. This was actually a special type of merge: the fast forward merge. If the other branch already has all the commits from the current branch, Git will just add the commits from the other branch and point both branches at the same place. It&#8217;s like git is treating the commits from the fixing-bug branch as commits on the master branch.</p>
<p>Now let&#8217;s merge the changes from our testing-theory branch. This will conflict with the bug fix we just checked in, since both commits add to the first line. Usually Git is good at automatically merging, so changing two separate pieces of code in the same file won&#8217;t result in a conflict. In this example, we&#8217;ll have to resolve it. If conflicts are found, Git will leave markers in the conflicting files. After you fix the conflicts, you can run a commit to complete the merge.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ git merge testing-theory
Auto-merging file1
CONFLICT <span style="color: #7a0874; font-weight: bold;">&#40;</span>content<span style="color: #7a0874; font-weight: bold;">&#41;</span>: Merge conflict <span style="color: #000000; font-weight: bold;">in</span> file1
Automatic merge failed; fix conflicts and <span style="color: #000000; font-weight: bold;">then</span> commit the result. 
Kleinschs-Macbook:first nick$ <span style="color: #c20cb9; font-weight: bold;">cat</span> file1
<span style="color: #000000; font-weight: bold;">&lt;&lt;&lt;&lt;&lt;&lt;&lt;</span> HEAD:file1
secondEdit - add to first line
=======
secondEdit
&nbsp;
added a line
<span style="color: #000000; font-weight: bold;">&gt;&gt;&gt;&gt;&gt;&gt;&gt;</span> testing-theory:file1</pre></div></div>

<p>The first section shows the changes from master, the second shows the changes from testing-theory. Let&#8217;s keep both changes. I&#8217;m going to keep the first line from master and the last line from testing-theory.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ <span style="color: #c20cb9; font-weight: bold;">vi</span> file1 
Kleinschs-Macbook:first nick$ <span style="color: #c20cb9; font-weight: bold;">cat</span> file1 
secondEdit - add to first line
&nbsp;
added a line
Kleinschs-Macbook:first nick$ git status
file1: needs merge
<span style="color: #666666; font-style: italic;"># On branch master</span>
<span style="color: #666666; font-style: italic;"># Changed but not updated:</span>
<span style="color: #666666; font-style: italic;">#   (use &quot;git add &lt;file&gt;...&quot; to update what will be committed)</span>
<span style="color: #666666; font-style: italic;">#   (use &quot;git checkout -- &lt;file&gt;...&quot; to discard changes in working directory)</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#	unmerged:   file1</span>
<span style="color: #666666; font-style: italic;">#</span>
no changes added to commit <span style="color: #7a0874; font-weight: bold;">&#40;</span>use <span style="color: #ff0000;">&quot;git add&quot;</span> and<span style="color: #000000; font-weight: bold;">/</span>or <span style="color: #ff0000;">&quot;git commit -a&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Now we&#8217;re ready to finish the merge. You commit this the same as a regular commit. Since testing-theory doesn&#8217;t have the bug fix that we used to patch master, this will not be a fast forward merge.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ git commit <span style="color: #660033;">-am</span><span style="color: #ff0000;">'Merged changes from testing-theory branch'</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>master d6132fa<span style="color: #7a0874; font-weight: bold;">&#93;</span> Merged changes from testing-theory branch
Kleinschs-Macbook:first nick$ gitk <span style="color: #660033;">--all</span></pre></div></div>

<p><img src="http://kleinsch.com/wp-content/uploads/2009/08/Branch-Merge-5.png" alt="Branch-Merge-5" title="Branch-Merge-5" width="320" height="77" class="alignnone size-full wp-image-82" /></p>
<p>The picture here gets a little complicated, but it shows that our master branch now incorporates changes from both the fixing-bug and testing-theory branches.</p>
<p>The complicated stuff is over! Just two more bits to clear up. Let&#8217;s create a branch and make some changes.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ git checkout <span style="color: #660033;">-b</span> another-branch
Switched to a new branch <span style="color: #ff0000;">'another-branch'</span>
Kleinschs-Macbook:first nick$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'bad-change'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> file2</pre></div></div>

<p>If you don&#8217;t like the change and want to get rid of it, you can use the checkout command to get rid of it. SVN users: the &#8216;revert&#8217; command in Git is <em>not</em> the same as the revert command in SVN! If you&#8217;re thinking of reverting changes made to a file, make sure to use the checkout command.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ git checkout file2
Kleinschs-Macbook:first nick$ <span style="color: #c20cb9; font-weight: bold;">cat</span> file2
anotherFile
Kleinschs-Macbook:first nick$ git status
<span style="color: #666666; font-style: italic;"># On branch another-branch</span>
nothing to commit <span style="color: #7a0874; font-weight: bold;">&#40;</span>working directory clean<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Let&#8217;s say it turns out you didn&#8217;t need this branch, let&#8217;s get rid of it. You first need to switch away from this branch. Then use the &#8216;-d&#8217; option to the branch command to delete unnecessary branches.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ git checkout master
Switched to branch <span style="color: #ff0000;">'master'</span>
Kleinschs-Macbook:first nick$ git branch <span style="color: #660033;">-d</span> another-branch
Deleted branch another-branch <span style="color: #7a0874; font-weight: bold;">&#40;</span>was d6132fa<span style="color: #7a0874; font-weight: bold;">&#41;</span>.
Kleinschs-Macbook:first nick$ git branch
  development
  fixing-bug
<span style="color: #000000; font-weight: bold;">*</span> master
  my-dev-branch
  testing-theory</pre></div></div>

<p>You can even delete the branches you&#8217;ve committed. This won&#8217;t mess up your branching history, it just removes the branch label from those commits.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ git branch <span style="color: #660033;">-d</span> fixing-bug
Deleted branch fixing-bug <span style="color: #7a0874; font-weight: bold;">&#40;</span>was 645e620<span style="color: #7a0874; font-weight: bold;">&#41;</span>.
Kleinschs-Macbook:first nick$ git branch <span style="color: #660033;">-d</span> testing-theory
Deleted branch testing-theory <span style="color: #7a0874; font-weight: bold;">&#40;</span>was 42a287a<span style="color: #7a0874; font-weight: bold;">&#41;</span>.
Kleinschs-Macbook:first nick$ git branch <span style="color: #660033;">-d</span> my-dev-branch
Deleted branch my-dev-branch <span style="color: #7a0874; font-weight: bold;">&#40;</span>was 5bd6207<span style="color: #7a0874; font-weight: bold;">&#41;</span>.
Kleinschs-Macbook:first nick$ gitk <span style="color: #660033;">--all</span></pre></div></div>

<p><img src="http://kleinsch.com/wp-content/uploads/2009/08/Branch-Merge-6.png" alt="Branch-Merge-6" title="Branch-Merge-6" width="318" height="67" class="alignnone size-full wp-image-83" /></p>
<p>This still shows the same history, we&#8217;ve just removed the named branches not in use. Finally, if you&#8217;re doing development, you may need to incorporate the changes that have gone into the master branch so you can start at the same point as your release.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ git checkout development
Switched to branch <span style="color: #ff0000;">'development'</span>
Kleinschs-Macbook:first nick$ git merge master
Updating 941bde0..d6132fa
Fast forward
 file1 <span style="color: #000000; font-weight: bold;">|</span>    <span style="color: #000000;">4</span> +++-
 <span style="color: #000000;">1</span> files changed, <span style="color: #000000;">3</span> insertions<span style="color: #7a0874; font-weight: bold;">&#40;</span>+<span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">1</span> deletions<span style="color: #7a0874; font-weight: bold;">&#40;</span>-<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Kleinschs-Macbook:first nick$ gitk <span style="color: #660033;">--all</span></pre></div></div>

<p><img src="http://kleinsch.com/wp-content/uploads/2009/08/Branch-Merge-7.png" alt="Branch-Merge-7" title="Branch-Merge-7" width="362" height="65" class="alignnone size-full wp-image-84" /></p>
<p>That&#8217;s about it for branching and merging. At this point the only thing the only major thing left is setting up remote operations. I&#8217;ll cover that in the next part of this tutorial.</p>
<img src="http://feeds.feedburner.com/~r/kleinsch/~4/mfl7Qq-jbyQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://kleinsch.com/2009/08/26/git-workflow-part-2-branches/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://kleinsch.com/2009/08/26/git-workflow-part-2-branches/</feedburner:origLink></item>
		<item>
		<title>A Simple Git Workflow</title>
		<link>http://feedproxy.google.com/~r/kleinsch/~3/VwpOtIoiCoI/</link>
		<comments>http://kleinsch.com/2009/08/15/a-simple-git-workflow/#comments</comments>
		<pubDate>Sat, 15 Aug 2009 13:59:55 +0000</pubDate>
		<dc:creator>Nick Kleinschmidt</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://kleinsch.com/?p=22</guid>
		<description><![CDATA[Setting up a Git repository is simple. You can use an existing directory or create something from scratch. I'll start out fresh. The 'init' command sets up a new repository.]]></description>
			<content:encoded><![CDATA[<p>I just started using Git for source control. Having used CVS and SVN extensively, I thought I had a decent background on version control and would be able to pick it up quickly. I quickly was overwhelmed by the amount of concepts and explanations needed in the documentation. Hint to the folks writing the <a href="http://book.git-scm.com/">Git book</a>: start with simple concepts and build up from there. I don&#8217;t need to know how Git stores its files in the first chapter. I don&#8217;t need to know what a fast forward merge is. Give me one chapter that has a simple workflow example, then jump into the explanations of the internals and advanced features. I had to read through 50 pages of the book to figure out a basic remote workflow. Here are some of the bits I&#8217;ve gleaned. I&#8217;m still a Git beginner, so tips are always appreciated.</p>
<p>I&#8217;ll assume you have Git set up already, there are tutorials on the web for the wide variety of supported platforms. Once you&#8217;re set up with Git, you should be able to run &#8216;git &#8211;version&#8217; at the command line and see a version string (like &#8220;git version 1.6.3.2&#8243;). All git commands are run in the format &#8216;git COMMAND_NAME OPTIONS&#8217;. Running &#8216;git &#8211;help&#8217; will list all commands. Running &#8216;git help COMMAND_NAME&#8217; will give a man page about that command. For example, to get information about the add command, you can run &#8216;git help add&#8217;.</p>
<p>Setting up a Git repository is simple. You can use an existing directory or create something from scratch. I&#8217;ll start out fresh. The &#8216;init&#8217; command sets up a new repository.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:tmp nick$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> first <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">cd</span> first
Kleinschs-Macbook:first nick$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'firstEdit'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> file1
Kleinschs-Macbook:first nick$ git init</pre></div></div>

<p>Now we&#8217;re set up with a Git repository in this directory. The &#8217;status&#8217; command gives you information about your working set.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ git status
<span style="color: #666666; font-style: italic;"># On branch master</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Initial commit</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Untracked files:</span>
<span style="color: #666666; font-style: italic;">#   (use &quot;git add ...&quot; to include in what will be committed)</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#	file1</span>
nothing added to commit but untracked files present <span style="color: #7a0874; font-weight: bold;">&#40;</span>use <span style="color: #ff0000;">&quot;git add&quot;</span> to track<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>To make a commit in Git, you first do an &#8216;add&#8217; of all files you want to be included in the commit, then a &#8216;commit&#8217;. The commit command will prompt for a message using your favorite editor, or you can use the &#8216;-m&#8217; flag to add the message at the command line.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ git add file1
Kleinschs-Macbook:first nick$ git status
<span style="color: #666666; font-style: italic;"># On branch master</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Initial commit</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Changes to be committed:</span>
<span style="color: #666666; font-style: italic;">#   (use &quot;git rm --cached ...&quot; to unstage)</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#	new file:   file1</span>
<span style="color: #666666; font-style: italic;">#</span>
Kleinschs-Macbook:first nick$ git commit <span style="color: #660033;">-m</span><span style="color: #ff0000;">'First commit'</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>master <span style="color: #7a0874; font-weight: bold;">&#40;</span>root-commit<span style="color: #7a0874; font-weight: bold;">&#41;</span> 4cc0433<span style="color: #7a0874; font-weight: bold;">&#93;</span> first <span style="color: #c20cb9; font-weight: bold;">file</span>
<span style="color: #000000;">1</span> files changed, <span style="color: #000000;">1</span> insertions<span style="color: #7a0874; font-weight: bold;">&#40;</span>+<span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">0</span> deletions<span style="color: #7a0874; font-weight: bold;">&#40;</span>-<span style="color: #7a0874; font-weight: bold;">&#41;</span>
create mode <span style="color: #000000;">100644</span> file1
Kleinschs-Macbook:first nick$ git status
<span style="color: #666666; font-style: italic;"># On branch master</span>
nothing to commit <span style="color: #7a0874; font-weight: bold;">&#40;</span>working directory clean<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Let&#8217;s say we want to make a change. We&#8217;ll modify the first file and add another.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'secondEdit'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> file1
Kleinschs-Macbook:first nick$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'anotherFile'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> file2
Kleinschs-Macbook:first nick$ git status
<span style="color: #666666; font-style: italic;"># On branch master</span>
<span style="color: #666666; font-style: italic;"># Changed but not updated:</span>
<span style="color: #666666; font-style: italic;">#   (use &quot;git add ...&quot; to update what will be committed)</span>
<span style="color: #666666; font-style: italic;">#   (use &quot;git checkout -- ...&quot; to discard changes in working directory)</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#	modified:   file1</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Untracked files:</span>
<span style="color: #666666; font-style: italic;">#   (use &quot;git add ...&quot; to include in what will be committed)</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#	file2</span>
no changes added to commit <span style="color: #7a0874; font-weight: bold;">&#40;</span>use <span style="color: #ff0000;">&quot;git add&quot;</span> and<span style="color: #000000; font-weight: bold;">/</span>or <span style="color: #ff0000;">&quot;git commit -a&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Git detects that we&#8217;ve changed one file and added another. If you want to see the changes you made, you can use the &#8216;diff&#8217; command to show a diff of the files.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ git <span style="color: #c20cb9; font-weight: bold;">diff</span> file1
<span style="color: #c20cb9; font-weight: bold;">diff</span> <span style="color: #660033;">--git</span> a<span style="color: #000000; font-weight: bold;">/</span>file1 b<span style="color: #000000; font-weight: bold;">/</span>file1
index dc2bdc4..1837f2f <span style="color: #000000;">100644</span>
<span style="color: #660033;">---</span> a<span style="color: #000000; font-weight: bold;">/</span>file1
+++ b<span style="color: #000000; font-weight: bold;">/</span>file1
<span style="color: #000000; font-weight: bold;">@@</span> <span style="color: #660033;">-1</span> +<span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">@@</span>
<span style="color: #660033;">-firstEdit</span>
+secondEdit</pre></div></div>

<p>We could add the change and commit, but there&#8217;s a slightly easier way. As the status output describes, you can use the &#8216;-a&#8217; flag for commit to automatically commit all modified files. It will not add new files, you&#8217;ll still have to do add those yourself. Let&#8217;s add the second file and commit the whole thing.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ git add file2
Kleinschs-Macbook:first nick$ git commit <span style="color: #660033;">-am</span><span style="color: #ff0000;">'Made a second commit!'</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>master 74ec253<span style="color: #7a0874; font-weight: bold;">&#93;</span> Made a second commit<span style="color: #000000; font-weight: bold;">!</span>
<span style="color: #000000;">2</span> files changed, <span style="color: #000000;">2</span> insertions<span style="color: #7a0874; font-weight: bold;">&#40;</span>+<span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">1</span> deletions<span style="color: #7a0874; font-weight: bold;">&#40;</span>-<span style="color: #7a0874; font-weight: bold;">&#41;</span>
create mode <span style="color: #000000;">100644</span> file2
Kleinschs-Macbook:first nick$ git status
<span style="color: #666666; font-style: italic;"># On branch master</span>
nothing to commit <span style="color: #7a0874; font-weight: bold;">&#40;</span>working directory clean<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>The last thing to cover for right now is looking at past history. You use the &#8216;log&#8217; command to view commit history.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Kleinschs-Macbook:first nick$ git log file1
commit 8ebf88b3d99309c1bd245156459a24549cf11ee8
Author: Nick Kleinschmidt <span style="color: #000000; font-weight: bold;">&lt;</span>nick.kleinschmidt<span style="color: #000000; font-weight: bold;">@</span>gmail.com<span style="color: #000000; font-weight: bold;">&gt;</span>
Date:   Sat Aug <span style="color: #000000;">15</span> 09:<span style="color: #000000;">28</span>:<span style="color: #000000;">26</span> <span style="color: #000000;">2009</span> <span style="color: #660033;">-0400</span>
&nbsp;
    Made a second commit<span style="color: #000000; font-weight: bold;">!</span>
&nbsp;
commit 7801dc66b2b3b5029e888ad35e5f0405584b4ff1
Author: Nick Kleinschmidt <span style="color: #000000; font-weight: bold;">&lt;</span>nick.kleinschmidt<span style="color: #000000; font-weight: bold;">@</span>gmail.com<span style="color: #000000; font-weight: bold;">&gt;</span>
Date:   Sat Aug <span style="color: #000000;">15</span> 09:<span style="color: #000000;">24</span>:<span style="color: #000000;">47</span> <span style="color: #000000;">2009</span> <span style="color: #660033;">-0400</span>
&nbsp;
    first commit
Kleinschs-Macbook:first nick$ git log file2
commit 8ebf88b3d99309c1bd245156459a24549cf11ee8
Author: Nick Kleinschmidt <span style="color: #000000; font-weight: bold;">&lt;</span>nick.kleinschmidt<span style="color: #000000; font-weight: bold;">@</span>gmail.com<span style="color: #000000; font-weight: bold;">&gt;</span>
Date:   Sat Aug <span style="color: #000000;">15</span> 09:<span style="color: #000000;">28</span>:<span style="color: #000000;">26</span> <span style="color: #000000;">2009</span> <span style="color: #660033;">-0400</span>
&nbsp;
    Made a second commit<span style="color: #000000; font-weight: bold;">!</span></pre></div></div>

<p>With this setup, you can work locally, changing and committing to your hearts content. At this point, it&#8217;s fairly similar to most traditional version control systems. There&#8217;s still a lot to cover! Next time, I&#8217;ll get into setting up a remote repository, then we&#8217;ll dive into branching and merging.</p>
<img src="http://feeds.feedburner.com/~r/kleinsch/~4/VwpOtIoiCoI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://kleinsch.com/2009/08/15/a-simple-git-workflow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://kleinsch.com/2009/08/15/a-simple-git-workflow/</feedburner:origLink></item>
		<item>
		<title>Setting up WordPress on Debian 5.0</title>
		<link>http://feedproxy.google.com/~r/kleinsch/~3/5lDYZM3OGsA/</link>
		<comments>http://kleinsch.com/2009/08/01/setting-up-wordpress-on-debian-5-0/#comments</comments>
		<pubDate>Sat, 01 Aug 2009 16:07:45 +0000</pubDate>
		<dc:creator>Nick Kleinschmidt</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://kleinsch.com/?p=6</guid>
		<description><![CDATA[I'll assume you're starting with a stock Debian 5.0 system and have set up sudo access for your account. I'll be using the user nick as my personal user for this setup.

First we need install the prerequisites: Apache, PHP, and MySQL. It'll ask you for a root password for MySQL, make sure you hold onto that. We'll need it later.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll assume you&#8217;re starting with a stock Debian 5.0 system and have set up sudo access for your account. I&#8217;ll be using the user nick as my personal user for this setup.</p>
<p>First we need install the prerequisites: Apache, PHP, and MySQL. It&#8217;ll ask you for a root password for MySQL, make sure you hold onto that. We&#8217;ll need it later.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> apache2 mysql-server php5 php5-mysql</pre></div></div>

<p>Now we need to make sure that Apache is configured with the modules needed for Wordpress.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> a2enmod rewrite
<span style="color: #c20cb9; font-weight: bold;">sudo</span> a2enmod php5</pre></div></div>

<p>WordPress uses a MySQL database to store your blog posts and comments, so we need to create a MySQL database for wordpress. MySQL will ask you for the root password you created before. Make sure to save the password you set up for the wordpress user, as this is what WordPress will use to connect to the database.</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">mysql <span style="color: #CC0099;">-</span>u root <span style="color: #CC0099;">-</span>p
<span style="color: #990099; font-weight: bold;">CREATE</span> <span style="color: #990099; font-weight: bold;">DATABASE</span> <span style="color: #008000;">`wordpress`</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">grant</span> <span style="color: #990099; font-weight: bold;">all</span> <span style="color: #990099; font-weight: bold;">privileges</span> <span style="color: #990099; font-weight: bold;">on</span> <span style="color: #008000;">`wordpress`</span>.<span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">to</span> <span style="color: #008000;">'wordpress'</span>@localhost identified by <span style="color: #008000;">'ANOTHER-PASSWORD'</span><span style="color: #000033;">;</span> 
flush <span style="color: #990099; font-weight: bold;">privileges</span><span style="color: #000033;">;</span></pre></div></div>

<p>Need to set up WordPress with a directory so we can use it. Download WordPress from their <a href="http://wordpress.org/download/">site</a> and stick it in your home directory.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> sites <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">cd</span> sites
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> ~nick<span style="color: #000000; font-weight: bold;">/</span>wordpress-2.8.2.tar.gz .
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">tar</span> xzvf wordpress-2.8.2.tar.gz
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">touch</span> wordpress<span style="color: #000000; font-weight: bold;">/</span>.htaccess
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> nick:www-data wordpress
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #660033;">-R</span> g+<span style="color: #c20cb9; font-weight: bold;">w</span> wordpress</pre></div></div>

<p>We changed the group and gave write permissions so WordPress will be able to set up its own config files. We set up the .htaccess file in advance because it&#8217;s easier to let WordPress change it based on the URL settings.</p>
<p>In order to serve the website, we need to set up an Apache Virtual Host. Create a file in /etc/apache/sites-available (mine is kleinsch.com) for your site and add the following code.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;VirtualHost</span> *:80<span style="color: #000000; font-weight: bold;">&gt;</span></span>
        ServerName kleinsch.com
        ServerAlias www.kleinsch.com
        ServerAdmin youremail@yourhost.com
        DocumentRoot /var/www/sites/wordpress
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Directory</span> /var/www/sites/wordpress<span style="color: #000000; font-weight: bold;">&gt;</span></span>
                Options FollowSymLinks
                AllowOverride All
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Directory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/VirtualHost<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Enable the site within Apache and restart:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> a2ensite kleinsch.com
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache restart</pre></div></div>

<p>You should see no warnings. Open up your browser and navigate to &#8216;http://yoursite.com/wp-admin/install.php&#8217;.</p>
<p>The first page will tell you WordPress needs to create a config file, we want it to do that. On the next page, enter the database information you set up above. Leave the defaults for the encoding and table prefix. Enter a title for your blog, and you&#8217;re up and running!</p>
<img src="http://feeds.feedburner.com/~r/kleinsch/~4/5lDYZM3OGsA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://kleinsch.com/2009/08/01/setting-up-wordpress-on-debian-5-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://kleinsch.com/2009/08/01/setting-up-wordpress-on-debian-5-0/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 1.112 seconds. --><!-- Cached page generated by WP-Super-Cache on 2010-07-26 10:37:30 -->
