<?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>git &#8211; richliu&#039;s blog</title>
	<atom:link href="https://richliu.com/tag/git/feed/" rel="self" type="application/rss+xml" />
	<link>https://richliu.com</link>
	<description>Linux, 工作, 生活, 家人</description>
	<lastBuildDate>Mon, 30 Dec 2013 14:16:44 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>git subversion</title>
		<link>https://richliu.com/2013/12/30/1593/git-subversion/</link>
					<comments>https://richliu.com/2013/12/30/1593/git-subversion/#comments</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Mon, 30 Dec 2013 14:16:44 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=1593</guid>

					<description><![CDATA[<p>git 真是很難操控的東西. 好像寫了很多次, 但是都忘記怎麼用.. # git svn clone svn: [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2013/12/30/1593/git-subversion/">git subversion</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>git 真是很難操控的東西. 好像寫了很多次, 但是都忘記怎麼用..<br />
<span id="more-1593"></span><br />
# git svn clone svn://blah blah </p>
<p>Update source code.<br />
# git svn fetch<br />
# git svn rebase </p>
<p>git 不能用 bare 當作 svn 的 repository. 只能用 work repository<br />
所以如果有其他目錄 clone 出去要 commit 進來時, 可以用這個指令</p>
<p># git push origin master:origin<br />
將自己的 master 推到 remote 的 origin 去, 有時候 origin 存在時無法 push, 就換另一個名字再 push. </p>
<p># git push origin master:origin3</p>
<p>然後在原來的 repository 應該就可以 commit 了<br />
# git svn dcommit</p>
<p>如果沒有辦法, 可以切到 master<br />
# git checkout master<br />
再下 cherry-pick (只上 patch), 如果什麼都不下, 就是只上一個 patch<br />
# git cherry-pick origin<br />
如果要上很多 patch<br />
# git cherry-pick start_patch^..end_patch<br />
這邊要用 start_patch 的前一版, 我也不知道為什麼啦. </p>
<p>如果一次改了很多 bug 要分別 patch<br />
可以用<br />
# git add -p<br />
這時候就會一個 diff 一個 diff 列, 命令列還有 s (split), e(edit) 可以將 diff 分成兩個和修改. </p>
<p>做完之後<br />
# git diff &#8211;cached<br />
看己經儲存的 patch<br />
# git commit<br />
不能用 -a , 這樣會連其他的一起 commit </p>
<p>commit 錯了<br />
# git reset HEAD^<br />
可以重新 commit 一次<br />
清除 code.<br />
# git reset &#8211;hard<br />
如果只是打錯 commit 的說明<br />
# git commit &#8211;amend</p>
<p>其他太複雜的就暫時不研究了. </p>
<p>The post <a rel="nofollow" href="https://richliu.com/2013/12/30/1593/git-subversion/">git subversion</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2013/12/30/1593/git-subversion/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>[GIT] 將現有的目錄改成 bare 並且修改 remote server</title>
		<link>https://richliu.com/2012/11/15/1351/git-%e5%b0%87%e7%8f%be%e6%9c%89%e7%9a%84%e7%9b%ae%e9%8c%84%e6%94%b9%e6%88%90-bare-%e4%b8%a6%e4%b8%94%e4%bf%ae%e6%94%b9-remote-server/</link>
					<comments>https://richliu.com/2012/11/15/1351/git-%e5%b0%87%e7%8f%be%e6%9c%89%e7%9a%84%e7%9b%ae%e9%8c%84%e6%94%b9%e6%88%90-bare-%e4%b8%a6%e4%b8%94%e4%bf%ae%e6%94%b9-remote-server/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Wed, 14 Nov 2012 17:56:08 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[bare]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[remote]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=1351</guid>

					<description><![CDATA[<p>git 如果從另一個目錄 clone 出來, 兩邊都有 source code, 是不能直接 master p [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2012/11/15/1351/git-%e5%b0%87%e7%8f%be%e6%9c%89%e7%9a%84%e7%9b%ae%e9%8c%84%e6%94%b9%e6%88%90-bare-%e4%b8%a6%e4%b8%94%e4%bf%ae%e6%94%b9-remote-server/">[GIT] 將現有的目錄改成 bare 並且修改 remote server</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>git 如果從另一個目錄 clone 出來, 兩邊都有 source code, 是不能直接 master push 到 master 的.<br />
會出現錯誤訊息<br />
[TEXT]<br />
git push error &#8216;[remote rejected] master -> master (branch is currently checked out)&#8217;<br />
[/TEXT]</p>
<p>這時可以產生另一個 bare 目錄, 然後到 git 目錄內下指令, 將該目錄變成 bare<br />
[BASH]<br />
# cp -a (path_to_source_dir) (path_to_bare_dir)<br />
# cd (path_to_bare_dir)<br />
# git config &#8211;bool core.bare true<br />
# rm (all source code)<br />
# mv .git/* .<br />
# rmdir .git<br />
[/BASH]</p>
<p>這樣就可以了. </p>
<p>原來的目錄可以修改 remote url 的方式指到新的目錄<br />
[BASH]<br />
# cd (path_to_source_dir)<br />
# git remote set-url origin //(path_to_bare_dir)<br />
[/BASH]</p>
<p>這時有 source code 的目錄還是用 git push/pull 更新 source code.<br />
如果是 bare 的話就是 git push, git fetch/merge 更新 source code. </p>
<p>Ref web.<br />
<a href="http://stackoverflow.com/questions/2816369/git-push-error-remote-rejected-master-master-branch-is-currently-checked" target="_blank" rel="noopener">http://stackoverflow.com/questions/2816369/git-push-error-remote-rejected-master-master-branch-is-currently-checked</a><br />
<a href="http://stackoverflow.com/questions/2432764/how-to-change-a-remote-repository-uri-using-git" target="_blank" rel="noopener">http://stackoverflow.com/questions/2432764/how-to-change-a-remote-repository-uri-using-git</a></p>
<p>The post <a rel="nofollow" href="https://richliu.com/2012/11/15/1351/git-%e5%b0%87%e7%8f%be%e6%9c%89%e7%9a%84%e7%9b%ae%e9%8c%84%e6%94%b9%e6%88%90-bare-%e4%b8%a6%e4%b8%94%e4%bf%ae%e6%94%b9-remote-server/">[GIT] 將現有的目錄改成 bare 並且修改 remote server</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2012/11/15/1351/git-%e5%b0%87%e7%8f%be%e6%9c%89%e7%9a%84%e7%9b%ae%e9%8c%84%e6%94%b9%e6%88%90-bare-%e4%b8%a6%e4%b8%94%e4%bf%ae%e6%94%b9-remote-server/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>git 筆記: 如何將現有的 Tree 推到 remote</title>
		<link>https://richliu.com/2011/11/01/1133/git-%e7%ad%86%e8%a8%98-%e5%a6%82%e4%bd%95%e5%b0%87%e7%8f%be%e6%9c%89%e7%9a%84-tree-%e6%8e%a8%e5%88%b0-remote/</link>
					<comments>https://richliu.com/2011/11/01/1133/git-%e7%ad%86%e8%a8%98-%e5%a6%82%e4%bd%95%e5%b0%87%e7%8f%be%e6%9c%89%e7%9a%84-tree-%e6%8e%a8%e5%88%b0-remote/#comments</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Mon, 31 Oct 2011 17:15:36 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[remote]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=1133</guid>

					<description><![CDATA[<p>我本來在開發 AMP 的程式, 所以從 source code clone 了一個新的開發目錄, 稱 A, 再 [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2011/11/01/1133/git-%e7%ad%86%e8%a8%98-%e5%a6%82%e4%bd%95%e5%b0%87%e7%8f%be%e6%9c%89%e7%9a%84-tree-%e6%8e%a8%e5%88%b0-remote/">git 筆記: 如何將現有的 Tree 推到 remote</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>我本來在開發 AMP 的程式, 所以從 source code clone 了一個新的開發目錄, 稱 A, 再從 A clone 一個新的開發目錄, 稱 B.<br />
這時在 B 的目錄下, 沒有辦法直接 push 回 A , 因為 A 內有 source code , 所以只好再開一個新的空 git, 往上推. </p>
<p>假設主要的 tracking branch name 是 major. (一般用 origin or master, btw, 我是從別的地方再 clone 過來的, 所以不用此名)<br />
創立一個新的空 git 目錄.<br />
[BASH]<br />
$ cd /data/prj/AMP/core-data<br />
$ git init &#8211;bare<br />
[/BASH]</p>
<p>在 source code A 下, 建立一個新的 remote<br />
[BASH]<br />
$ git remote add test /data/prj/AMP/core-data<br />
$ git push test major<br />
[/BASH]</p>
<p>在 source code B 下, 加入一個新的 remote, 用 git reset &#8211;hard 是清除所有的改變, 以便 pull<br />
[BASH]<br />
$ git diff<br />
$ git reset &#8211;hard<br />
$ git remote add  test /data/prj/AMP/core-data/bare/<br />
$ git pull test major<br />
[/BASH]</p>
<p>* 若是遇到這種情形, 可以檢查是不是這個檔在是 untracked, 可以用 $ git status 查看. 如果是 untracked, 可以刪除.<br />
[BASH]<br />
$ git pull test major<br />
From /data/prj/AMP/core-data/bare<br />
 * branch            major      -> FETCH_HEAD<br />
error: Untracked working tree file &#8216;kernels/linux-2.6.35.12/arch/arm/kernel/real-amp.c&#8217; would be overwritten by merge.  Aborting<br />
[/BASH]</p>
<p>git 功能太多 :-/</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2011/11/01/1133/git-%e7%ad%86%e8%a8%98-%e5%a6%82%e4%bd%95%e5%b0%87%e7%8f%be%e6%9c%89%e7%9a%84-tree-%e6%8e%a8%e5%88%b0-remote/">git 筆記: 如何將現有的 Tree 推到 remote</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2011/11/01/1133/git-%e7%ad%86%e8%a8%98-%e5%a6%82%e4%bd%95%e5%b0%87%e7%8f%be%e6%9c%89%e7%9a%84-tree-%e6%8e%a8%e5%88%b0-remote/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>git 和 filesystem 的 Performance</title>
		<link>https://richliu.com/2011/07/24/1109/git-%e5%92%8c-filesystem-%e7%9a%84-performance/</link>
					<comments>https://richliu.com/2011/07/24/1109/git-%e5%92%8c-filesystem-%e7%9a%84-performance/#comments</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Sat, 23 Jul 2011 16:00:54 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[btrfs]]></category>
		<category><![CDATA[ext3]]></category>
		<category><![CDATA[ext4]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[peformance]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[xfs]]></category>
		<category><![CDATA[問題]]></category>
		<category><![CDATA[效能]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=1109</guid>

					<description><![CDATA[<p>前二天因為硬碟壞掉, 所以硬碟升級成 raid1. 而 file system 手賤換成 xfs. 這個星期我 [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2011/07/24/1109/git-%e5%92%8c-filesystem-%e7%9a%84-performance/">git 和 filesystem 的 Performance</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>前二天因為硬碟壞掉, 所以硬碟升級成 raid1. 而 file system 手賤換成 xfs.<br />
這個星期我都在查詢 system 的 performance 問題.</p>
<p>因為我 git 的各項操作實在是太慢了.<br />
慢到整個系統大概可以和 P5 比吧 (反正就是慢慢慢)<br />
<span id="more-1109"></span><br />
一開始我以為是 raid/disk 的問題, 不過在數次交叉測試下, 看起來兇手指向 File System<br />
以下就是我的測試環境.</p>
<p>CPU: Intel(R) Core(TM)2 Quad CPU    Q9550  @ 2.83GHz<br />
OS: Ubuntu Linux 10.04 LTS<br />
HDD1: Device Model:     Seagate ST31000528AS (1T)<br />
HDD2: Device Model:     Seagate ST31000528AS (1T)<br />
同一顆.</p>
<p>測試方式.</p>
<p>HDD1, HDD2 分別切了 40G 的 Primary 1 Partition.<br />
第一次在 HDD1 測 ext4 , HDD2 測 xfs<br />
第二次在 HDD1 測 xfs , HDD2 測 ext3<br />
第二次測完後追加 ext3 和 btrfs<br />
使用 time command 測試時間.<br />
在 Copy 之前會先 mkfs disk .<br />
硬碟內先行準備好一個 git repository 的測試資料, 然後再另建一個目錄 clone 這份測試資料(不細測 Read/Write)</p>
<p>測試資料.<br />
9.1G 的 .git source tree. 包含 5G 的 .git database 還有 4.1G 的 source code/binary/image .. 等等資料. 約有 2800 個 commit.</p>
<p>以下是測試數據<br />
First Round<br />
sda1: ext4<br />
# time git clone ../trunk/<br />
Initialized empty Git repository in /mnt/disk/1/trunk/.git/<br />
Checking out files: 100% (216892/216892), done.</p>
<p>real 3m30.381s<br />
user 0m24.878s<br />
sys 0m31.402s</p>
<p>sdb1: xfs<br />
# time git clone ../trunk/<br />
Initialized empty Git repository in /mnt/disk2/1/trunk/.git/<br />
Checking out files: 100% (216892/216892), done.</p>
<p>real 13m47.297s<br />
user 0m31.510s<br />
sys 0m24.482s</p>
<p>Round 2:<br />
sda1: xfs<br />
# time git clone ../trunk/<br />
Initialized empty Git repository in /mnt/disk/1/trunk/.git/<br />
Checking out files: 100% (216892/216892), done.</p>
<p>real 13m10.405s<br />
user 0m32.122s<br />
sys 0m19.761s</p>
<p>sdb1: ext4<br />
# time git clone ../trunk/<br />
Initialized empty Git repository in /mnt/disk2/1/trunk/.git/<br />
Checking out files: 100% (216892/216892), done.</p>
<p>real 1m25.192s<br />
user 0m26.210s<br />
sys 0m14.017s</p>
<p>sdb: ext3<br />
# time git clone ../trunk/<br />
Initialized empty Git repository in /mnt/disk2/1/trunk/.git/<br />
Checking out files: 100% (216892/216892), done.</p>
<p>real 3m5.792s<br />
user 0m25.534s<br />
sys 0m23.065s</p>
<p>sda: btrfs<br />
# time git clone ../trunk/<br />
Initialized empty Git repository in /mnt/disk/1/trunk/.git/<br />
Checking out files: 100% (216892/216892), done.</p>
<p>real 1m13.981s<br />
user 0m24.670s<br />
sys 0m32.730s</p>
<p>簡單的做一個圖表做測試結果.</p>
<p><a href="https://richliu.com/wp-content/uploads/2011/07/time.png"><img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-1110" title="time" src="https://richliu.com/wp-content/uploads/2011/07/time.png" alt="" width="483" height="292" srcset="https://richliu.com/wp-content/uploads/2011/07/time.png 483w, https://richliu.com/wp-content/uploads/2011/07/time-300x181.png 300w" sizes="(max-width: 483px) 100vw, 483px" /></a></p>
<p>由此圖可知, 我的效能問題是出在 xfs 上.將 raid system 改成 ext4 後, 這個問題就解決了.</p>
<p>但是奇怪的是, xfs 雖然花了 13m, 但是實際 CPU 使用時間並不多. 這個問題也有可能是 ubuntu/Linux kernel 造成的.</p>
<p>ext4 和  btrfs 都各有一次不錯的表現. 尤其是 btrfs, 才 1m13 秒. 大家有常常使用 git 的, 可以考慮一下 btrfs.</p>
<p>受限於個人時間, 這個測試並不嚴謹, 不過己經可以解決我目前的問題, 至於這個數據, 簡單整理一下以後, 可以給常常使用 git 的朋友一個參考的資料.<br />
接下來就是希望有人能夠花點時間做出更完整的數據, 或是順便 Debug 了. </p>
<p>The post <a rel="nofollow" href="https://richliu.com/2011/07/24/1109/git-%e5%92%8c-filesystem-%e7%9a%84-performance/">git 和 filesystem 的 Performance</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2011/07/24/1109/git-%e5%92%8c-filesystem-%e7%9a%84-performance/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>git gc: Out of memory, malloc failed</title>
		<link>https://richliu.com/2011/04/22/1050/git-gc-out-of-memory-malloc-failed/</link>
					<comments>https://richliu.com/2011/04/22/1050/git-gc-out-of-memory-malloc-failed/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Fri, 22 Apr 2011 11:46:47 +0000</pubDate>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[gc]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[out of memory]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=1050</guid>

					<description><![CDATA[<p>不知道什麼時候, 跑 Git gc 的時候, 會出現這樣的訊息. 但是這並不是主系統記憶體太小(事實上我有 8 [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2011/04/22/1050/git-gc-out-of-memory-malloc-failed/">git gc: Out of memory, malloc failed</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>不知道什麼時候, 跑 Git gc 的時候, 會出現這樣的訊息.<br />
但是這並不是主系統記憶體太小(事實上我有 8G).</p>
<p><span id="more-1050"></span></p>
<p>解決方案是在 repack 時, 在 memory scale 使用較小的 memory<br />
這樣就不會因為 small object 太多, 太快吃掉所有的 memory .</p>
<p>語法<br />
[BASH]<br />
$ git repack -adf &#8211;window=memory<br />
[/BASH]</p>
<p>跑完一次 repack 之後, 接下來就可以正常跑 GC 了.<br />
以下是我的 Log<br />
[BASH]<br />
root@rl-desktop:/data/git-pool/vega-base/trunk# git gc<br />
Counting objects: 174589, done.<br />
Delta compression using up to 4 threads.<br />
fatal: Out of memory, malloc failed09843)<br />
error: failed to run repack<br />
root@rl-desktop:/data/git-pool/vega-base/trunk# git repack -adf &#8211;window=5<br />
Counting objects: 174589, done.<br />
Delta compression using up to 4 threads.<br />
warning: suboptimal pack &#8211; out of memory)<br />
fatal: Out of memory, malloc failed69814)<br />
root@rl-desktop:/data/git-pool/vega-base/trunk# git repack -adf &#8211;window=2<br />
Counting objects: 174589, done.<br />
Delta compression using up to 4 threads.<br />
fatal: Out of memory, malloc failed69814)<br />
root@rl-desktop:/data/git-pool/vega-base/trunk# git repack -adf &#8211;window=1<br />
Counting objects: 174589, done.<br />
Delta compression using up to 4 threads.<br />
Compressing objects: 100% (169814/169814), done.<br />
Writing objects: 100% (174589/174589), done.<br />
Total 174589 (delta 77228), reused 0 (delta 0)<br />
root@rl-desktop:/data/git-pool/vega-base/trunk# git gc<br />
Counting objects: 174589, done.<br />
Delta compression using up to 4 threads.<br />
Compressing objects: 100% (92586/92586), done.<br />
Writing objects: 100% (174589/174589), done.<br />
Total 174589 (delta 77228), reused 174589 (delta 77228)<br />
root@rl-desktop:/data/git-pool/vega-base/trunk#<br />
[/BASH]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2011/04/22/1050/git-gc-out-of-memory-malloc-failed/">git gc: Out of memory, malloc failed</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2011/04/22/1050/git-gc-out-of-memory-malloc-failed/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
