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

<channel>
	<title>brool &#187; git</title>
	<atom:link href="http://www.brool.com/index.php/tag/git/feed" rel="self" type="application/rss+xml" />
	<link>http://www.brool.com</link>
	<description>brool \brool\ (n.) : a low roar; a deep murmur or humming</description>
	<lastBuildDate>Fri, 20 Jan 2012 07:58:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Posting To WordPress From Git</title>
		<link>http://www.brool.com/index.php/posting-to-wordpress-from-git</link>
		<comments>http://www.brool.com/index.php/posting-to-wordpress-from-git#comments</comments>
		<pubDate>Mon, 27 Jul 2009 20:57:20 +0000</pubDate>
		<dc:creator>tim</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.brool.com/?p=302</guid>
		<description><![CDATA[I&#8217;ve found WordPress to be pretty decent, aside from the security updates every other week, but for me writing is a very spur of the moment thing; I prefer to be able to go into Emacs and just immediately type anything without having to log into my blog, create a new post, and then suffer [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve found WordPress to be pretty decent, aside from the security updates every other week, but for me writing is a very spur of the moment thing;  I prefer to be able to go into Emacs and just immediately type anything without having to log into my blog, create a new post, and then suffer through a web editor.  Basically, I want to do it in Emacs!  Now!  And maybe I&#8217;m offline!</p>

<p>So, I wrote a tiny little program to help facilitate using git and WordPress together through the XMLRPC API, and it&#8217;s helped me write&#8230; well, if not <i>more</i> than at least <i>less painfully</i>.</p>

<h3>Setting Up</h3>
<p>Assuming that your blog is set up at http://www.yourblog.com (you can create an account at wordpress.com to test this out), all you&#8217;ll need to do is:</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="bash"><pre class="de1"><span class="re5">--</span> <span class="kw2">make</span> a directory <span class="kw1">for</span> the blog
<span class="kw2">mkdir</span> blog
chdir blog
&nbsp;
<span class="re5">--</span> download everything
python wp.py download <span class="re5">--user</span>=yourname <span class="re5">--password</span>=yourpass <span class="re5">--url</span>=http:<span class="sy0">//</span>www.yourblog.com<span class="sy0">/</span>xmlrpc.php
<span class="br0">&#40;</span><span class="kw3">wait</span> a bit<span class="br0">&#41;</span>
<span class="kw2">git init</span>
<span class="kw2">git add</span> .
<span class="kw2">git commit</span> <span class="re5">-m</span> <span class="st0">&quot;first version&quot;</span>
&nbsp;
<span class="re5">--</span> now <span class="kw1">set</span> up so we don<span class="st_h">'t have to specify --user, --password, and --url every time (optional)
git wp config wp.url http://www.yourblog.com/xmlrpc.php
git wp config wp.user yourname
git wp config wp.password yourpass</span></pre></div></div></div></div></div></div></div>




<p>The files are downloaded in the appropriate YYYY/MM directories, with the draft directory being used for all of your unpublished drafts.</p>

<p>All the drafts are stored in plain text, but you&#8217;ll see some lines starting with periods &#8212; these are various WordPress variables that are associated with the file.  You can change them, as well;  for example, to change the title of the post, just change the line that begins with &#8220;.title&#8221;. </p>

<h3>Seeing What&#8217;s Different</h3>
<p>You can use the status command to see differences between the local file system and your blog.</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="bash"><pre class="de1">python wp.py status</pre></div></div></div></div></div></div></div>




<h3>Updating From The Blog</h3>
<p>If you&#8217;ve made changes through the web interface and you&#8217;d like to bring them down, you don&#8217;t have to download everything again, but can instead just update.</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="bash"><pre class="de1">python wp.py update</pre></div></div></div></div></div></div></div>




<h3>Posting/Editing</h3>
<p>If you&#8217;d like to edit a post, just edit it, and then use wp post to push it back to the blog:</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="bash"><pre class="de1">python wp.py post changed-file</pre></div></div></div></div></div></div></div>




<p>To create a new post, just create a new file in the draft folder &#8212; I like to specify the .title and .wp_slug parameters, as well &#8212; and then post it.  You can also publish it by changing the .post_status line from draft to publish.

<h3>Gotchas</h3>

<p>While this program <i>requires</i> git, it doesn&#8217;t automatically check anything in &#8212; so you&#8217;ll need to make sure you do git add / git commit or whatnot as necessary.</p>

<p>There are also some gotchas due to the fact that the filename can change on you.  There are cases where the filename that will be brought down is different then the one that you send up:</p>
<ul>
<li>You post a file without a .title or .wp_slug line</li>
<li>You post a file with a different file name than the slug that is generated (i.e., &#8220;my-first-draft&#8221; when the title is actually &#8220;my final draft&#8221;)</li>
<li>Something moves from &#8220;draft&#8221; to &#8220;publish&#8221;
</ul>

<p>When you see a message of the form &#8220;changed: fn1 -> fn2&#8243;, it means that a rename has occurred, and you&#8217;ll need to do the git rm/git add or git mv by hand.</p>

<h3>Source</h3>
<a href="http://github.com/brool/git-wordpress/tree/master">Source is available on github</a>.]]></content:encoded>
			<wfw:commentRss>http://www.brool.com/index.php/posting-to-wordpress-from-git/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Recovering From A &#8211;hard Reset In Git</title>
		<link>http://www.brool.com/index.php/recovering-from-a-hard-reset-in-git</link>
		<comments>http://www.brool.com/index.php/recovering-from-a-hard-reset-in-git#comments</comments>
		<pubDate>Sun, 19 Apr 2009 06:37:09 +0000</pubDate>
		<dc:creator>tim</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[hard]]></category>
		<category><![CDATA[recovering]]></category>
		<category><![CDATA[reset]]></category>

		<guid isPermaLink="false">http://www.brool.com/?p=303</guid>
		<description><![CDATA[I was switching between git repositories the other day, and managed to do a &#8220;git reset &#8211;hard HEAD^&#8221; in the wrong repository. Which wasn&#8217;t bad, since I had most of the files already open in Emacs&#8230; but then Emacs calmly told me that it was re-reading the files from disk. But, git had everything still [...]]]></description>
			<content:encoded><![CDATA[I was switching between git repositories the other day, and managed to do a &#8220;git reset &#8211;hard HEAD^&#8221; in the wrong repository.  Which wasn&#8217;t bad, since I had most of the files already open in Emacs&#8230; but then Emacs calmly told me that it was re-reading the files from disk.

But, git had everything still around &#8212; it turns out to be pretty easy to get it back.  The magic command turned out to be git reflog.


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="bash"><pre class="de1">$ <span class="kw2">git reflog</span>
aba2b93... HEAD<span class="sy0">@</span><span class="br0">&#123;</span><span class="nu0">0</span><span class="br0">&#125;</span>: reset <span class="re5">--hard</span> HEAD^
28a0c01... HEAD<span class="sy0">@</span><span class="br0">&#123;</span><span class="nu0">1</span><span class="br0">&#125;</span>: commit: <span class="kw2">more</span> work on pre-receive
1c4a3af... HEAD<span class="sy0">@</span><span class="br0">&#123;</span><span class="nu0">2</span><span class="br0">&#125;</span>: merge tmp: Fast forward
84d69cb... HEAD<span class="sy0">@</span><span class="br0">&#123;</span><span class="nu0">3</span><span class="br0">&#125;</span>: checkout: moving to commit_hooks
1c4a3af... HEAD<span class="sy0">@</span><span class="br0">&#123;</span><span class="nu0">4</span><span class="br0">&#125;</span>: commit: commit hooks
a489ebd... HEAD<span class="sy0">@</span><span class="br0">&#123;</span><span class="nu0">5</span><span class="br0">&#125;</span>: checkout: moving to tmp
a489ebd... HEAD<span class="sy0">@</span><span class="br0">&#123;</span><span class="nu0">6</span><span class="br0">&#125;</span>: checkout: moving to a489ebd</pre></div></div></div></div></div></div></div>




So I had lost everything in HEAD@{1}, but you can get it back by just checking out that particular commit.


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="bash"><pre class="de1">$ <span class="kw2">git checkout</span> HEAD<span class="sy0">@</span><span class="br0">&#123;</span><span class="nu0">1</span><span class="br0">&#125;</span>
Note: moving to <span class="st0">&quot;28a0c01&quot;</span> <span class="kw2">which</span> isn<span class="st_h">'t a local branch
If you want to create a new branch from this checkout, you may do so
(now or later) by using -b with the checkout command again. Example:
  git checkout -b &lt;new_branch_name&gt;
HEAD is now at 28a0c01... commit: more work on pre-receive
&nbsp;
$ git checkout -b tmp
... do whatever you need to do to get tmp to the right state ...
&nbsp;
$ git checkout master
$ git merge tmp</span></pre></div></div></div></div></div></div></div>




Note that if I didn&#8217;t need to fiddle around with stuff, but just had wanted everything in the commit, I could just have merged the entire commit:


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="bash"><pre class="de1"><span class="co4">$ </span><span class="kw2">git merge</span> HEAD<span class="sy0">@</span><span class="br0">&#123;</span><span class="nu0">1</span><span class="br0">&#125;</span></pre></div></div></div></div></div></div></div>




&#8230; and that would have brought everything back to the state I needed.]]></content:encoded>
			<wfw:commentRss>http://www.brool.com/index.php/recovering-from-a-hard-reset-in-git/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Poison Reverts in Git</title>
		<link>http://www.brool.com/index.php/poison-reverts-in-git</link>
		<comments>http://www.brool.com/index.php/poison-reverts-in-git#comments</comments>
		<pubDate>Fri, 22 Aug 2008 23:47:23 +0000</pubDate>
		<dc:creator>tim</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://www.brool.com/?p=102</guid>
		<description><![CDATA[Alice owns the main branch that a bunch of people are using: A -- B -- C -- D Bob checks it out, makes changes 0..2, and does regular pulls: A -- B -- 0 -- 1 -- C -- 2 -- D Now, Alice pulls Bob&#8217;s stuff: she has A -- B -- C [...]]]></description>
			<content:encoded><![CDATA[<p>Alice owns the main branch that a bunch of people are using:  <code>A -- B -- C -- D</code></p>
<p>Bob checks it out, makes changes 0..2, and does regular pulls:  <code>A -- B -- 0 -- 1 -- C -- 2 -- D</code></p>

<p>Now, Alice pulls Bob&#8217;s stuff:  she has <code>A -- B -- C -- D -- (0 + 1 + 2)</code></p>
<p>Alice pulls from another developer:  <code>A -- B -- C -- D -- (0 + 1 + 2) -- E</code></p>

<p>Bob&#8217;s patch is bad!  How did it get through the audits and QA and unit tests?  No matter, revert it.  Alice now has:</p>
<code>A -- B -- C -- D -- (0+1+2) -- E -- (-0 -1 -2)</code>

<p>(Note that Alice can&#8217;t rebase Bob&#8217;s changes out of the history because other developers are pulling from her).</p>

<p>Bob sees that his commits didn&#8217;t work, is properly chastened, and makes a fix titled &#8220;3&#8243;.</p>

<p>Now, see the problem:</p>
<ul><li>If Bob pulls from Alice, he&#8217;ll either get a merge conflict if he&#8217;s made changes, or his stuff will get deleted out of his repo (!)</li>
<li>If Alice pulls from Bob, then she&#8217;ll have problems &#8212; her mainline thinks that it&#8217;s already taken Bob&#8217;s changes, but now he&#8217;s trying to change a deleted file.</li>
</ul>

<p>So it looks like Git is in a situation where someone or the other (or both) are going to have to do a painful merge conflict resolution.  There must be a better way of reverting a patch?</p>

<p><b>Update 3/20/2009</b>:  The <a href="http://www.kernel.org/pub/software/scm/git/docs/howto/revert-a-faulty-merge.txt">word from Linus</a> on this.  He says that when you unrevert the merge that you always need to revert the revert, rather than trying to apply it again.</p>]]></content:encoded>
			<wfw:commentRss>http://www.brool.com/index.php/poison-reverts-in-git/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

