<?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>vm-kernel &#187; Git</title>
	<atom:link href="http://vm-kernel.org/blog/category/git/feed/" rel="self" type="application/rss+xml" />
	<link>http://vm-kernel.org/blog</link>
	<description>All about emulation and virtualization</description>
	<lastBuildDate>Sat, 17 Apr 2010 03:51:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>a misunderstanding of git-checkout</title>
		<link>http://vm-kernel.org/blog/2008/12/12/a-misunderstanding-of-git-checkout/</link>
		<comments>http://vm-kernel.org/blog/2008/12/12/a-misunderstanding-of-git-checkout/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 07:51:10 +0000</pubDate>
		<dc:creator>yajin</dc:creator>
				<category><![CDATA[Git]]></category>
		<category><![CDATA[git-checkout]]></category>
		<category><![CDATA[git-switch-branch]]></category>

		<guid isPermaLink="false">http://vm-kernel.org/blog/2008/12/12/a-misunderstanding-of-git-checkout/</guid>
		<description><![CDATA[I work in branch master and there are some changes uncommited. Now I have some ideas and want to try it *without* effecting the branch master. I first create a branch test and then checkout to branch test.

kill-bill:/home/root/sdc/qemu/qemu-omap/svn# git branch test

kill-bill:/home/root/sdc/qemu/qemu-omap/svn# git checkout test

Switched to branch &#34;test&#34;

kill-bill:/home/root/sdc/qemu/qemu-omap/svn# git branch

 master

*test

And then I work in branch [...]]]></description>
			<content:encoded><![CDATA[<p align="justify">I work in branch master and there are some changes uncommited. Now I have some ideas and want to try it *without* effecting the branch master. I first create a branch test and then checkout to branch test.</p>
<pre style="border-right: #cecece 1px solid; padding-right: 5px; border-top: #cecece 1px solid; padding-left: 5px; min-height: 40px; padding-bottom: 5px; overflow: auto; border-left: #cecece 1px solid; padding-top: 5px; border-bottom: #cecece 1px solid; background-color: #e9e9e9">
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #e9e9e9">kill-bill:/home/root/sdc/qemu/qemu-omap/svn# git branch test
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #e9e9e9">kill-bill:/home/root/sdc/qemu/qemu-omap/svn# git checkout test
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #e9e9e9">Switched to branch &quot;<span style="color: #8b0000">test</span>&quot;
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #e9e9e9">kill-bill:/home/root/sdc/qemu/qemu-omap/svn# git branch
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #e9e9e9"> master
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #e9e9e9">*test</pre>
</pre>
<p align="justify">And then I work in branch test and make some changes to source file a.c b.c and etc. At last, I want to return to branch master and abandon the changes in branch test. But the result is not same as what I thought. The files changed in branch test are also changed in branch master!!</p>
<p align="justify">Git-checkout DOES NOT save your context and uncommitted changes to somewhere and restore them when you return. If you want git to do so, please use <a href="http://code.google.com/p/git-switch-branch/" target="_blank">git-switch-branch</a> instead.</p>
]]></content:encoded>
			<wfw:commentRss>http://vm-kernel.org/blog/2008/12/12/a-misunderstanding-of-git-checkout/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>混合使用Git SVN和Git</title>
		<link>http://vm-kernel.org/blog/2008/10/24/%e6%b7%b7%e5%90%88%e4%bd%bf%e7%94%a8git-svn%e5%92%8cgit/</link>
		<comments>http://vm-kernel.org/blog/2008/10/24/%e6%b7%b7%e5%90%88%e4%bd%bf%e7%94%a8git-svn%e5%92%8cgit/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 16:45:00 +0000</pubDate>
		<dc:creator>yajin</dc:creator>
				<category><![CDATA[Git]]></category>

		<guid isPermaLink="false">http://vm-kernel.org/blog/2008/10/24/%e6%b7%b7%e5%90%88%e4%bd%bf%e7%94%a8git-svn%e5%92%8cgit/</guid>
		<description><![CDATA[上一篇文章中，介绍了如何在google code中使用Git svn。现在又有了新问题。比如项目qemu-omap3是想往开源项目qemu中增加一个新的功能。qemu-omap3的项目hosting是在google code上面，使用Git svn来管理。而qemu在http://repo.or.cz/w/qemu.git，使用Git来管理。
为了开发qemu-omap3，需要从某一天的qemu中拿下来所有的源码，然后在这个基础上进行开发。但问题在于qemu的开发也同时在进行。这就需要qemu-omap3中的代码能保持和qemu中的同步。也就是说，我的需求如下：
1.&#160; 使用git svn来管理qemu-omap3 
2. 能得到最新的qemu的代码
3. 最新的qemu的代码不影响我的qemu-omap3 

之前解决的方法是定期从qemu中拿下所有的源码，然后在qemu-omap3中建立一个branch，然后拷贝过去，进行merage。这个过程比较繁琐。
实际上，可以通过git remote命令来增加一个新的remote repo。
git remote add qemu http://repo.or.cz/r/qemu.git
git fetch qemu

这会在git中自动建立一个branch qemu并且会将所有的qemu中的branch等全部放到qemu下。下面是目前我的branch。
kill-bill:/home/root/sdc/qemu/qemu-omap/svn# git-branch -a      * master       &#160; qemu/master       &#160; qemu/svn/perso       &#160; qemu/svn/tags/initial   [...]]]></description>
			<content:encoded><![CDATA[<p align="justify"><a href="http://vm-kernel.org/blog/2008/10/15/%e5%9c%a8google-code%e4%b8%ad%e4%bd%bf%e7%94%a8git/">上一篇文章中</a>，介绍了如何在google code中使用Git svn。现在又有了新问题。比如项目qemu-omap3是想往开源项目qemu中增加一个新的功能。qemu-omap3的项目hosting是在google code上面，使用Git svn来管理。而qemu在<a href="http://repo.or.cz/w/qemu.git">http://repo.or.cz/w/qemu.git</a>，使用Git来管理。</p>
<p align="justify">为了开发qemu-omap3，需要从某一天的qemu中拿下来所有的源码，然后在这个基础上进行开发。但问题在于qemu的开发也同时在进行。这就需要qemu-omap3中的代码能保持和qemu中的同步。也就是说，我的需求如下：</p>
<blockquote><p align="justify">1.&#160; 使用git svn来管理qemu-omap3 </p>
<p align="justify">2. 能得到最新的qemu的代码</p>
<p align="justify">3. 最新的qemu的代码不影响我的qemu-omap3 </p>
</blockquote>
<p align="justify">之前解决的方法是定期从qemu中拿下所有的源码，然后在qemu-omap3中建立一个branch，然后拷贝过去，进行merage。这个过程比较繁琐。</p>
<p align="justify">实际上，可以通过git remote命令来增加一个新的remote repo。</p>
<blockquote><p align="justify">git remote add qemu <a href="http://repo.or.cz/r/qemu.git">http://repo.or.cz/r/qemu.git</a></p>
<p align="justify">git fetch qemu</p>
</blockquote>
<p align="justify">这会在git中自动建立一个branch qemu并且会将所有的qemu中的branch等全部放到qemu下。下面是目前我的branch。</p>
<blockquote><p align="justify">kill-bill:/home/root/sdc/qemu/qemu-omap/svn# git-branch -a      <br />* master       <br />&#160; qemu/master       <br />&#160; qemu/svn/perso       <br />&#160; qemu/svn/tags/initial       <br />&#160; qemu/svn/tags/release_0_5_1       <br />&#160; qemu/svn/tags/release_0_6_0       <br />&#160; qemu/svn/tags/release_0_6_1       <br />&#160; qemu/svn/tags/release_0_7_0       <br />&#160; qemu/svn/tags/release_0_7_1       <br />&#160; qemu/svn/tags/release_0_8_1       <br />&#160; qemu/svn/tags/release_0_8_2       <br />&#160; qemu/svn/tags/release_0_9_0       <br />&#160; qemu/svn/tags/release_0_9_1       <br />&#160; qemu/svn/trunk       <br />&#160; trunk</p>
</blockquote>
<p align="justify">接下来需要merage 目前的master和qemu上的master。首先新建一个local branch</p>
<blockquote><p align="justify">git merage qemu/master</p>
</blockquote>
<p align="justify">这个命令会将qemu/master 和本地的branch merage。由于我们本地的branch是在master，因此会merage到master。如果有冲突出现，有提示。然后在修改，git-add 后，冲突就没有了。</p>
<p align="justify">以后可以通过git fetch qemu来获取qemu的最新代码。并且通过git merage来合并远程的qemu和本地的代码。不过有一点要注意，这样merage的不仅仅是代码，而且包括log!!</p>
<p align="justify">然后使用git svn dcommit提交到google code上。svn上的log只会是你自己的log，而不是merage过来的很多其他log。</p>
]]></content:encoded>
			<wfw:commentRss>http://vm-kernel.org/blog/2008/10/24/%e6%b7%b7%e5%90%88%e4%bd%bf%e7%94%a8git-svn%e5%92%8cgit/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>在google code中使用git</title>
		<link>http://vm-kernel.org/blog/2008/10/15/%e5%9c%a8google-code%e4%b8%ad%e4%bd%bf%e7%94%a8git/</link>
		<comments>http://vm-kernel.org/blog/2008/10/15/%e5%9c%a8google-code%e4%b8%ad%e4%bd%bf%e7%94%a8git/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 16:30:36 +0000</pubDate>
		<dc:creator>yajin</dc:creator>
				<category><![CDATA[Git]]></category>

		<guid isPermaLink="false">http://vm-kernel.org/blog/2008/10/15/%e5%9c%a8google-code%e4%b8%ad%e4%bd%bf%e7%94%a8git/</guid>
		<description><![CDATA[相比sf，googlecode的使用更加简单和方便。虽然在功能方面没有sf多，但是对于一个开源项目来说，基本上够用了。google code的功能有wiki，下载，svn，issue report。最近googlecode的svn中又增加了一个code review的功能，也就是说别人可以浏览SVN中代码并且留下comment。详细见google的介绍：http://code.google.com/p/support/wiki/CodeReviews
虽然google提供的SVN功能不错，但是我喜欢在本地用GIT来管理我的代码。之前我的使用方法是用svn co下来一份代码，然后git建一个本地仓库，所有的代码修改log都进入本地仓库。当完成一个功能后，用svn commit进googlecode。这样做的缺点在于本地git的log不能反应到svn中。也就是说svn中的log信息都是比较粗线条的，不能很细化的反应项目的变化情况。
于是就需要请出我们今天的主角：git-svn。首先在ubuntu中安装它。
sudo apt-get install git-svn

&#160;&#160;&#160; 安装完以后，需要checkout出google code svn中的东西来。
git-svn clone https://omap3emu.googlecode.com/svn -T trunk -b branches -t tags

这会在本地生成一个文件夹svn。里面就是google code svn中的东西。请记住，GIT的远端仓库和本地目录都是在一起的。我们来看一下目前的GIT仓库中有哪些branch。
 

root@kill-bill:/home/root/sdc/omap3emu/svn#git-branch -a
* master      &#160; trunk

为什么有两个branch呢？请注意，git-svn会为svn中的trunk在GIT中建立一个branch，并且新建另外一个branch与其对应。比如目前omap3emu的svn中只有一个trunk，没有branch和tag，因此git会建立一个git的branch叫做trunk，并且还会建另外一个branch：master。master和trunk有对应关系。也就是说，git master对应到git trunk，git的trunk又对应到svn的trunk。至于这个对应关系有什么用，接下来会解释。
接下来就是在git的master中进行修改，然后git-commit，再修改，再commit。不过请记住，在git中进行的commit都是在本地。如果想commit到svn中怎么办呢？那就需要dcommit了。还有一个问题，我怎么知道是commit到svn的哪一个分支中呢？是 trunk，还是branch，还是tag？上面的对应关系就显出作用了。由于GIT中的master和svn中的trunk有对应关系，因此在 master中所做的改变使用dcommit到svn的时候是commit到svn的trunk中的。如果不知道将要进行的commit是commit到 svn的哪里，可以在dcommit后加入参数 -n 来查看。
root@kill-bill:/home/root/sdc/omap3emu/svn# git-svn dcommit -n      Committing to https://omap3emu.googlecode.com/svn/trunk ...     [...]]]></description>
			<content:encoded><![CDATA[<p align="justify">相比sf，googlecode的使用更加简单和方便。虽然在功能方面没有sf多，但是对于一个开源项目来说，基本上够用了。google code的功能有wiki，下载，svn，issue report。最近googlecode的svn中又增加了一个code review的功能，也就是说别人可以浏览SVN中代码并且留下comment。详细见google的介绍：<a href="http://code.google.com/p/support/wiki/CodeReviews">http://code.google.com/p/support/wiki/CodeReviews</a></p>
<p align="justify">虽然google提供的SVN功能不错，但是我喜欢在本地用GIT来管理我的代码。之前我的使用方法是用svn co下来一份代码，然后git建一个本地仓库，所有的代码修改log都进入本地仓库。当完成一个功能后，用svn commit进googlecode。这样做的缺点在于本地git的log不能反应到svn中。也就是说svn中的log信息都是比较粗线条的，不能很细化的反应项目的变化情况。</p>
<p align="justify">于是就需要请出我们今天的主角：git-svn。首先在ubuntu中安装它。</p>
<blockquote><p align="justify">sudo apt-get install git-svn</p>
</blockquote>
<p align="justify">&#160;&#160;&#160; 安装完以后，需要checkout出google code svn中的东西来。</p>
<blockquote><p align="justify">git-svn clone <a href="https://omap3emu.googlecode.com/svn">https://omap3emu.googlecode.com/svn</a> -T trunk -b branches -t tags</p>
</blockquote>
<p align="justify">这会在本地生成一个文件夹svn。里面就是google code svn中的东西。请记住，GIT的远端仓库和本地目录都是在一起的。我们来看一下目前的GIT仓库中有哪些branch。</p>
<p> <span id="more-10"></span><br />
<blockquote>
<p align="justify">root@kill-bill:/home/root/sdc/omap3emu/svn#git-branch -a</p>
<p align="justify">* master      <br />&#160; trunk</p>
</blockquote>
<p align="justify">为什么有两个branch呢？请注意，git-svn会为svn中的trunk在GIT中建立一个branch，并且新建另外一个branch与其对应。比如目前omap3emu的svn中只有一个trunk，没有branch和tag，因此git会建立一个git的branch叫做trunk，并且还会建另外一个branch：master。master和trunk有对应关系。也就是说，git master对应到git trunk，git的trunk又对应到svn的trunk。至于这个对应关系有什么用，接下来会解释。</p>
<p align="justify">接下来就是在git的master中进行修改，然后git-commit，再修改，再commit。不过请记住，在git中进行的commit都是在本地。如果想commit到svn中怎么办呢？那就需要dcommit了。还有一个问题，我怎么知道是commit到svn的哪一个分支中呢？是 trunk，还是branch，还是tag？上面的对应关系就显出作用了。由于GIT中的master和svn中的trunk有对应关系，因此在 master中所做的改变使用dcommit到svn的时候是commit到svn的trunk中的。如果不知道将要进行的commit是commit到 svn的哪里，可以在dcommit后加入参数 -n 来查看。</p>
<blockquote><p align="justify">root@kill-bill:/home/root/sdc/omap3emu/svn# git-svn dcommit -n      <br />Committing to <a href="https://omap3emu.googlecode.com/svn/trunk">https://omap3emu.googlecode.com/svn/trunk</a> ...       <br />diff-tree 8dab0ad6120a4ffc6bf4d7598098ec94f251216f~1 8dab0ad6120a4ffc6bf4d7598098ec94f251216f</p>
</blockquote>
<p align="justify">上面的显示告诉我们，将要进行的commit是commit'到svn的trunk中。别担心，加上参数-n后并没有进行真正的svn commit。如果想commit的话，去掉-n 参数。</p>
<blockquote><p align="justify">root@kill-bill:/home/root/sdc/omap3emu/svn# git-svn dcommit      <br />Committing to <a href="https://omap3emu.googlecode.com/svn/trunk">https://omap3emu.googlecode.com/svn/trunk</a> ...       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; A&#160;&#160;&#160;&#160;&#160;&#160; doc/codingstyle.txt       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; A&#160;&#160;&#160;&#160;&#160;&#160; doc/git-svn.txt       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; A&#160;&#160;&#160;&#160;&#160;&#160; doc/misc.txt       <br />Committed r2       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; A&#160;&#160;&#160;&#160;&#160;&#160; doc/codingstyle.txt       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; A&#160;&#160;&#160;&#160;&#160;&#160; doc/git-svn.txt       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; A&#160;&#160;&#160;&#160;&#160;&#160; doc/misc.txt       <br />r2 = 7bf572689c8fbd3852c5d5d197c434cc8b1c7345 (trunk)       <br />No changes between current HEAD and refs/remotes/trunk       <br />Resetting to the latest refs/remotes/trunk</p>
</blockquote>
<p align="justify">如果其他项目成员有了新改动并且commit到svn中去了。那么可以通过git-svn rebase来获得svn上的最新内容。</p>
<blockquote><p align="justify">root@kill-bill:/home/root/sdc/omap3emu/svn# git-svn rebase      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; M&#160;&#160;&#160;&#160;&#160;&#160; doc/misc.txt       <br />r3 = b279f0326a313acf8da146566ef3853edca91628 (trunk)       <br />First, rewinding head to replay your work on top of it...       <br />HEAD is now at b279f03... jsut a test       <br />Fast-forwarded master to refs/remotes/trunk.</p>
</blockquote>
<p align="justify">暂时算是简单的把git-svn用起来了，以后有什么复杂的情况，再继续介绍。这里有一篇更详细的文章<a href="http://quirkygba.blogspot.com/2007/10/using-git-with-google-code-hosting.html">using Git with Google code hosting</a>。非常不错。</p>
]]></content:encoded>
			<wfw:commentRss>http://vm-kernel.org/blog/2008/10/15/%e5%9c%a8google-code%e4%b8%ad%e4%bd%bf%e7%94%a8git/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
