<?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>workflow &#8211; 記下來</title>
	<atom:link href="https://noter.tw/tag/workflow/feed/" rel="self" type="application/rss+xml" />
	<link>https://noter.tw</link>
	<description>一路上踩到的坑、遇到的問題，一點一滴記下來，希望能幫助到需要的人~</description>
	<lastBuildDate>Sat, 07 Nov 2020 15:19:39 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.3</generator>

<image>
	<url>https://noter.tw/wp-content/uploads/cropped-old-1130742_1920-1-32x32.jpg</url>
	<title>workflow &#8211; 記下來</title>
	<link>https://noter.tw</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>[參考文章] 使用 Git 做為網站開發版本控管工具</title>
		<link>https://noter.tw/2626/%e5%8f%83%e8%80%83%e6%96%87%e7%ab%a0-%e4%bd%bf%e7%94%a8-git-%e5%81%9a%e7%82%ba%e7%b6%b2%e7%ab%99%e9%96%8b%e7%99%bc%e7%89%88%e6%9c%ac%e6%8e%a7%e7%ae%a1%e5%b7%a5%e5%85%b7/</link>
					<comments>https://noter.tw/2626/%e5%8f%83%e8%80%83%e6%96%87%e7%ab%a0-%e4%bd%bf%e7%94%a8-git-%e5%81%9a%e7%82%ba%e7%b6%b2%e7%ab%99%e9%96%8b%e7%99%bc%e7%89%88%e6%9c%ac%e6%8e%a7%e7%ae%a1%e5%b7%a5%e5%85%b7/#respond</comments>
		
		<dc:creator><![CDATA[黃小蛙]]></dc:creator>
		<pubDate>Wed, 02 Jan 2013 09:20:24 +0000</pubDate>
				<category><![CDATA[其他]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[hook]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[website]]></category>
		<category><![CDATA[workflow]]></category>
		<guid isPermaLink="false">http://wazai.net/?p=2626</guid>

					<description><![CDATA[<p>小蛙最近在找一個 website 開發上的解決方案，發現下面這篇文章可以符合小蛙的要求，本文主用小蛙自己的理解&#8221;記錄&#8221;下來。【A web-focused Git workflo&#46;&#46;&#46;</p>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/2626/%e5%8f%83%e8%80%83%e6%96%87%e7%ab%a0-%e4%bd%bf%e7%94%a8-git-%e5%81%9a%e7%82%ba%e7%b6%b2%e7%ab%99%e9%96%8b%e7%99%bc%e7%89%88%e6%9c%ac%e6%8e%a7%e7%ae%a1%e5%b7%a5%e5%85%b7/" data-wpel-link="internal">[參考文章] 使用 Git 做為網站開發版本控管工具</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></description>
										<content:encoded><![CDATA[
<p>小蛙最近在找一個 website 開發上的解決方案，發現下面這篇文章可以符合小蛙的要求，本文主用小蛙自己的理解&#8221;記錄&#8221;下來。<strong><a rel="noreferrer noopener nofollow external" href="http://joemaller.com/990/a-web-focused-git-workflow/" target="_blank" data-wpel-link="external" class="wpel-icon-right">【A web-focused Git workflow @ joe maller.com&nbsp;】<span class="wpel-icon wpel-image wpel-icon-6"></span></a></strong></p>



<span id="more-2626"></span>



<p>使用 <a rel="noreferrer noopener nofollow external" href="http://zh.wikipedia.org/wiki/Git" target="_blank" data-wpel-link="external" class="wpel-icon-right">Git<span class="wpel-icon wpel-image wpel-icon-6"></span></a> 做為版本控管非常好用，網路上有很多 Git 教學文：<br><strong><a rel="noreferrer noopener nofollow external" href="http://ihower.tw/blog/archives/5391/" target="_blank" data-wpel-link="external" class="wpel-icon-right">【Git and Github 演講投影片(2011) @ ihower { blogging }】<span class="wpel-icon wpel-image wpel-icon-6"></span></a></strong><br><strong><a rel="noreferrer noopener nofollow external" href="http://gogojimmy.net/2012/01/17/how-to-use-git-1-git-basic/" target="_blank" data-wpel-link="external" class="wpel-icon-right">【Git 教學(1) : Git 的基本使用 @ 好麻煩部落格】<span class="wpel-icon wpel-image wpel-icon-6"></span></a></strong><br><strong><a rel="noreferrer noopener nofollow external" href="http://blog.longwin.com.tw/2009/05/git-learn-initial-command-2009/" target="_blank" data-wpel-link="external" class="wpel-icon-right">【Git 初學筆記 &#8211; 指令操作教學 @ Tsung&#8217;s Blog】<span class="wpel-icon wpel-image wpel-icon-6"></span></a></strong><br></p>



<p>這篇文章參考自<strong><a rel="noreferrer noopener nofollow external" href="http://joemaller.com/990/a-web-focused-git-workflow/" target="_blank" data-wpel-link="external" class="wpel-icon-right">【A web-focused Git workflow @ joe maller.com&nbsp;】<span class="wpel-icon wpel-image wpel-icon-6"></span></a></strong>，以下文章指令輸入的部份源自於原始網頁，說明的部分是小蛙破英文翻過來的(只挑部份，沒有逐字翻)，連結到原始作者網頁可看到更多資訊。 </p>



<p>這邊原作者把架構拉開分成 3 種身份(點回作者網站可以看到架構圖)：<strong>Clones(副本)</strong>、<strong>Hub(匯整)</strong>、<strong>Prime(網站)</strong>。 </p>



<p>大致上的流程為：<strong>所有開發者從 Hub clone 一份下來開發，最後 push 回 Hub，再由 Hub 中的 hook 進入 Prime 的目錄下執行 pull，當 Prime 有 commit 動作時，也透過 hook 將變動 push 到 Hub 以維持兩個 repository 的一致性。</strong></p>



<p><strong>Hub</strong>: bare repository，其他開發者只能從這邊 clone 資料。</p>



<p><strong>Prime</strong>: standard repository，網站的目錄。 </p>



<p>安裝並設定 Git </p>



<pre class="wp-block-preformatted wp-block-syntaxhighlighter-code">git config --global user.name "Joe, working on the server"</pre>



<p>在網站目錄下初始化一個新的 Git repository (Prime) </p>



<pre class="wp-block-preformatted wp-block-syntaxhighlighter-code">cd ~/www
git init
git add .
git commit -m"initial import of pre-existing web files"</pre>



<p>在網站目錄之外的地方建立一個 bare repository (Hub) </p>



<pre class="wp-block-preformatted wp-block-syntaxhighlighter-code">cd; mkdir site_hub.git; cd site_hub.git
git --bare init
Initialized empty Git repository in /home/joe/site_hub.git</pre>



<p>從 Prime 目錄下，把 Hub 加入到 remote 中，並且把 Prime 上的 master push 到 Hub 上 </p>



<pre class="wp-block-preformatted wp-block-syntaxhighlighter-code">cd ~/www
git remote add hub ~/site_hub.git
git remote show hub
* remote hub
  URL: /home/joe/site_hub.git
git push hub master</pre>



<p>為了讓 hub 跟 prime 緊密連接在一起，且不影響到工作目錄結構，這邊作者在 Hub repository 上設定 post-update (<a rel="noreferrer noopener nofollow external" href="http://gitbook.liuhui998.com/5_8.html" target="_blank" data-wpel-link="external" class="wpel-icon-right">參考資料2<span class="wpel-icon wpel-image wpel-icon-6"></span></a>)，當 Hub 接收到更新(git push)時，便會切換到網站目錄(prime)下的 repository 執行 git pull 的動作 </p>



<pre class="wp-block-preformatted wp-block-syntaxhighlighter-code">#!/bin/sh
echo
echo "**** Pulling changes into Prime [Hub's post-update hook]"
echo
cd $HOME/www || exit
unset GIT_DIR
git pull hub master
exec git-update-server-info</pre>



<p>在 Prime repository 中加入 post-commit (<a rel="noreferrer noopener nofollow external" href="http://gitbook.liuhui998.com/5_8.html" target="_blank" data-wpel-link="external" class="wpel-icon-right">參考資料2<span class="wpel-icon wpel-image wpel-icon-6"></span></a>)，為了維持 hub 跟 prime 雙向一致，如果真的 Prime 被手動修改了，也可以立即將這個變動發送到 Hub 上，讓 Hub 知道這些變動，避免 conflict </p>



<pre class="wp-block-preformatted wp-block-syntaxhighlighter-code">#!/bin/sh
echo
echo "**** pushing changes to Hub [Prime's post-commit hook]"
echo
git push hub</pre>



<p>有一些情況下 Prime 跟 Hub 會發生不一致的情況，作者提到如果衝突發生時，最好的做法是先把目前發生問題的 Prime 的狀態 push 到 Hub 的 &#8220;fixme&#8221; 分支，如此一來其他的 clones 就可以把有問題的分支 pull 下來，處理完成後再 merge，以免因為 Git 的衝突標示使得網站無法正常運作 </p>



<pre class="wp-block-preformatted wp-block-syntaxhighlighter-code">git push hub master:refs/heads/fixme</pre>



<p>由於 Prime 的 .git 資料夾在網站的根目錄可能會有安全性的問題，使用 Apache 的話可以透過以下方式禁止 .git 被存取 </p>



<pre class="wp-block-preformatted wp-block-syntaxhighlighter-code"># deny access to the top-level git repository:
RewriteEngine On
RewriteRule \.git - [F,L]</pre>



<p>如果看到以下錯誤，就把 export PATH=${PATH}:~/bin 加入到 Server 上的 .bashrc 中。 </p>



<pre class="wp-block-preformatted wp-block-syntaxhighlighter-code">git-receive-pack: command not found
fatal: The remote end hung up unexpectedly</pre>



<h2 class="para wp-block-heading">參考資料</h2>



<ol class="my-li bg-darkblue wp-block-list"><li>A web-focused Git workflow @ joe maller.com<br><a href="http://joemaller.com/990/a-web-focused-git-workflow/" target="_blank" rel="noreferrer noopener nofollow external" data-wpel-link="external" class="wpel-icon-right">http://joemaller.com/990/a-web-focused-git-workflow/<span class="wpel-icon wpel-image wpel-icon-6"></span></a></li><li>Git Hooks @ Git Book 中文版<br><a href="http://gitbook.liuhui998.com/5_8.html" target="_blank" rel="noreferrer noopener nofollow external" data-wpel-link="external" class="wpel-icon-right">http://gitbook.liuhui998.com/5_8.html<span class="wpel-icon wpel-image wpel-icon-6"></span></a></li><li>Git @ 維基百科，自由的百科全書<br><a href="http://zh.wikipedia.org/wiki/Git" target="_blank" rel="noreferrer noopener nofollow external" data-wpel-link="external" class="wpel-icon-right">http://zh.wikipedia.org/wiki/Git<span class="wpel-icon wpel-image wpel-icon-6"></span></a></li><li>Git and Github 演講投影片(2011) @ ihower { blogging }<br><a href="http://ihower.tw/blog/archives/5391/" target="_blank" rel="noreferrer noopener nofollow external" data-wpel-link="external" class="wpel-icon-right">http://ihower.tw/blog/archives/5391/<span class="wpel-icon wpel-image wpel-icon-6"></span></a></li><li>Git 教學(1) : Git 的基本使用 @ 好麻煩部落格<br><a href="http://gogojimmy.net/2012/01/17/how-to-use-git-1-git-basic/" target="_blank" rel="noreferrer noopener nofollow external" data-wpel-link="external" class="wpel-icon-right">http://gogojimmy.net/2012/01/17/how-to-use-git-1-git-basic/<span class="wpel-icon wpel-image wpel-icon-6"></span></a></li><li>Git 初學筆記 &#8211; 指令操作教學 @ Tsung&#8217;s Blog<br><a href="http://blog.longwin.com.tw/2009/05/git-learn-initial-command-2009/" target="_blank" rel="noreferrer noopener nofollow external" data-wpel-link="external" class="wpel-icon-right">http://blog.longwin.com.tw/2009/05/git-learn-initial-command-2009/<span class="wpel-icon wpel-image wpel-icon-6"></span></a></li></ol>



<p><strong>Git 系列文章：</strong></p>



<ul class="my-li bg-darkblue wp-block-list"><li><a href="https://noter.tw/2563/git-gui-1-tortoisegit-msysgit-%e5%ae%89%e8%a3%9d/" data-wpel-link="internal">Git GUI – (1) TortoiseGit, msysgit 安裝</a></li><li><a href="https://noter.tw/2569/git-gui-2-%e8%a8%ad%e5%ae%9a%e3%80%81clone%e3%80%81add%e3%80%81modify/" data-wpel-link="internal">Git GUI – (2) 設定、Clone、Add、Modify</a></li><li><a href="https://noter.tw/2734/git-gui-3-branch%e3%80%81conflict%e3%80%81merge/" data-wpel-link="internal">Git GUI – (3) branch、conflict、merge</a></li><li><a href="https://noter.tw/2737/git-gui-4-fetch%e3%80%81merge%e3%80%81pull%e3%80%81%e8%a7%a3%e6%b1%ba%e8%a1%9d%e7%aa%81%e6%83%85%e6%b3%81conflict/" data-wpel-link="internal">Git GUI – (4) fetch、merge、pull、解決衝突情況(conflict)</a></li><li><a href="https://noter.tw/2626/%e5%8f%83%e8%80%83%e6%96%87%e7%ab%a0-%e4%bd%bf%e7%94%a8-git-%e5%81%9a%e7%82%ba%e7%b6%b2%e7%ab%99%e9%96%8b%e7%99%bc%e7%89%88%e6%9c%ac%e6%8e%a7%e7%ae%a1%e5%b7%a5%e5%85%b7/" data-wpel-link="internal">[參考文章] 使用 Git 做為網站開發版本控管工具</a></li></ul>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/2626/%e5%8f%83%e8%80%83%e6%96%87%e7%ab%a0-%e4%bd%bf%e7%94%a8-git-%e5%81%9a%e7%82%ba%e7%b6%b2%e7%ab%99%e9%96%8b%e7%99%bc%e7%89%88%e6%9c%ac%e6%8e%a7%e7%ae%a1%e5%b7%a5%e5%85%b7/" data-wpel-link="internal">[參考文章] 使用 Git 做為網站開發版本控管工具</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://noter.tw/2626/%e5%8f%83%e8%80%83%e6%96%87%e7%ab%a0-%e4%bd%bf%e7%94%a8-git-%e5%81%9a%e7%82%ba%e7%b6%b2%e7%ab%99%e9%96%8b%e7%99%bc%e7%89%88%e6%9c%ac%e6%8e%a7%e7%ae%a1%e5%b7%a5%e5%85%b7/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
