<?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 | SDT 攻城獅區</title>
	<atom:link href="https://sdt.hameba.tw/tag/git/feed/" rel="self" type="application/rss+xml" />
	<link>https://sdt.hameba.tw</link>
	<description>由Steven, Der, Ted 三位高級打字員所組成，是三位工程師(攻城獅)所維護的技術分享平台，或許偶爾會分享一些日常，有任何問題或是錯誤的部分，歡迎留言告訴我們！</description>
	<lastBuildDate>Sat, 29 Feb 2020 14:23:02 +0800</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.3</generator>

<image>
	<url>https://sdt.hameba.tw/wp-content/uploads/2020/02/hameba_favicon-150x150.png</url>
	<title>git | SDT 攻城獅區</title>
	<link>https://sdt.hameba.tw</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>在執行 Git 操作時，發生卡住的狀況</title>
		<link>https://sdt.hameba.tw/628/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e5%259c%25a8%25e5%259f%25b7%25e8%25a1%258c-git-%25e6%2593%258d%25e4%25bd%259c%25e6%2599%2582%25ef%25bc%258c%25e7%2599%25bc%25e7%2594%259f%25e5%258d%25a1%25e4%25bd%258f%25e7%259a%2584%25e7%258b%2580%25e6%25b3%2581</link>
				<comments>https://sdt.hameba.tw/628/#respond</comments>
				<pubDate>Sat, 29 Feb 2020 14:23:02 +0000</pubDate>
		<dc:creator><![CDATA[Ted]]></dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">https://sdt.hameba.tw/?p=628</guid>
				<description><![CDATA[<p>之前有發生過下 Git 指令時，終端機給了我這樣的訊息 [crayon-637a32809810e919813 &#8230; </p>
<p class="link-more"><a href="https://sdt.hameba.tw/628/" class="more-link">閱讀全文<span class="screen-reader-text">〈在執行 Git 操作時，發生卡住的狀況〉</span></a></p>
The post <a href="https://sdt.hameba.tw/628/">在執行 Git 操作時，發生卡住的狀況</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></description>
								<content:encoded><![CDATA[<p>之前有發生過下 Git 指令時，終端機給了我這樣的訊息</p><pre class="crayon-plain-tag">Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.</pre><p><span id="more-628"></span></p>
<p>後來查了一下，會發生這個原因，通常會是以下情況發生的</p>
<ol>
<li>同時執行了兩個 Git 的指令時，有可能一個操作是來自終端機，另一個來自 IDE。</li>
<li>有時強制關閉進行中的 Git 操作，這個檔案沒有被自動刪除，之後你就無法進行其他操作。</li>
</ol>
<p>發生這種狀況的時候，Git 通常會在此專案的 Git 資料夾裡面，產生一個 index.lock 的檔案，通常在進行某些比較費時的git操作時自動生成，操作結束後自動刪除，相當於一個鎖定檔案，目的在於防止對一個目錄同時進行多個操作。</p>
<p>要如何解決這個情形呢？</p>
<p>只要刪除 index.lock 檔案即可。</p><pre class="crayon-plain-tag">rm -f .git/index.lock</pre><p>參考資料：</p>
<p><a href="https://stackoverflow.com/questions/38004148/another-git-process-seems-to-be-running-in-this-repository">https://stackoverflow.com/questions/38004148/another-git-process-seems-to-be-running-in-this-repository</a></p>
<p><a href="https://iter01.com/331280.html">https://iter01.com/331280.html</a></p>
<p>&nbsp;</p>The post <a href="https://sdt.hameba.tw/628/">在執行 Git 操作時，發生卡住的狀況</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></content:encoded>
							<wfw:commentRss>https://sdt.hameba.tw/628/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
		<item>
		<title>Git fatal: The current branch  has no upstream branch.</title>
		<link>https://sdt.hameba.tw/585/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=git-fatal-the-current-branch-has-no-upstream-branch</link>
				<comments>https://sdt.hameba.tw/585/#respond</comments>
				<pubDate>Fri, 28 Feb 2020 07:59:56 +0000</pubDate>
		<dc:creator><![CDATA[Hsu Steven]]></dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[--set-upstream]]></category>
		<category><![CDATA[--unset-upstream]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[git branch]]></category>

		<guid isPermaLink="false">https://sdt.hameba.tw/?p=585</guid>
				<description><![CDATA[<p>使用git checkout &#60;name&#62;, 如果沒有會以當下的分支 create出新的分支， 但 &#8230; </p>
<p class="link-more"><a href="https://sdt.hameba.tw/585/" class="more-link">閱讀全文<span class="screen-reader-text">〈Git fatal: The current branch  has no upstream branch.〉</span></a></p>
The post <a href="https://sdt.hameba.tw/585/">Git fatal: The current branch  has no upstream branch.</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></description>
								<content:encoded><![CDATA[<p>使用git checkout &lt;name&gt;,</p>
<p>如果沒有會以當下的分支 create出新的分支，<span id="more-585"></span></p>
<p>但是當要git push會跳出提示訊息：</p>
<p>fatal: The current branch &lt;branchName&gt; has no upstream branch.</p>
<p>其實只是將目前分支設定好他遠端對應好的分支，</p>
<p>使用此指令：</p><pre class="crayon-plain-tag">// 追蹤分支的意思
$ git push --set-upstream origin branchName

// 取消追蹤分支,用到這個通常是遠端分支被刪除了！
$ git branch --unset-upstream</pre><p>&nbsp;</p>The post <a href="https://sdt.hameba.tw/585/">Git fatal: The current branch  has no upstream branch.</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></content:encoded>
							<wfw:commentRss>https://sdt.hameba.tw/585/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
		<item>
		<title>Git 建立與刪除遠端分支方式</title>
		<link>https://sdt.hameba.tw/583/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=git-%25e5%25bb%25ba%25e7%25ab%258b%25e8%2588%2587%25e5%2588%25aa%25e9%2599%25a4%25e9%2581%25a0%25e7%25ab%25af%25e5%2588%2586%25e6%2594%25af%25e6%2596%25b9%25e5%25bc%258f</link>
				<comments>https://sdt.hameba.tw/583/#respond</comments>
				<pubDate>Fri, 28 Feb 2020 07:50:58 +0000</pubDate>
		<dc:creator><![CDATA[Hsu Steven]]></dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[git push]]></category>

		<guid isPermaLink="false">https://sdt.hameba.tw/?p=583</guid>
				<description><![CDATA[<p>如果使用github, gitlab web GUI 應該都沒有什麼難事。 看到垃圾桶按鈕刪除即可&#8230 &#8230; </p>
<p class="link-more"><a href="https://sdt.hameba.tw/583/" class="more-link">閱讀全文<span class="screen-reader-text">〈Git 建立與刪除遠端分支方式〉</span></a></p>
The post <a href="https://sdt.hameba.tw/583/">Git 建立與刪除遠端分支方式</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></description>
								<content:encoded><![CDATA[<p>如果使用github, gitlab web GUI 應該都沒有什麼難事。</p>
<p>看到垃圾桶按鈕刪除即可&#8230;<span id="more-583"></span></p>
<p>所以主要這篇是使用指令來做遠端分支刪除的方式</p><pre class="crayon-plain-tag">$ git push steven :steven/master
To https://domain/username/repository.git
 - [deleted]         steven/master</pre><p>是的，你沒看錯，就是在分支前面加上冒號，而且是用 Push 指令來刪除遠端分支，</p>
<p>遠端建立分支指令：</p><pre class="crayon-plain-tag">$ git push remoteName master:steven</pre><p>這樣遠端remoteName位置 就會以 master 建立一個steven branch，</p>
<p>所以剛剛前面提到的 沒有帶上maste，也等同沒有basic所以會直接刪除的意思。</p>
<p>&nbsp;</p>
<p>Reference</p>
<p><a href="https://gitbook.tw/chapters/github/delete-remote-branch.html" target="_blank" rel="noopener noreferrer">https://gitbook.tw/chapters/github/delete-remote-branch.html</a></p>
<p>&nbsp;</p>The post <a href="https://sdt.hameba.tw/583/">Git 建立與刪除遠端分支方式</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></content:encoded>
							<wfw:commentRss>https://sdt.hameba.tw/583/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
		<item>
		<title>解決 git merge 不同分支出現 fatal: refusing to merge unrelated histories</title>
		<link>https://sdt.hameba.tw/580/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e8%25a7%25a3%25e6%25b1%25ba-git-merge-%25e4%25b8%258d%25e5%2590%258c%25e5%2588%2586%25e6%2594%25af%25e5%2587%25ba%25e7%258f%25be-fatal-refusing-to-merge-unrelated-histories</link>
				<comments>https://sdt.hameba.tw/580/#respond</comments>
				<pubDate>Fri, 28 Feb 2020 07:40:54 +0000</pubDate>
		<dc:creator><![CDATA[Hsu Steven]]></dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[merge]]></category>

		<guid isPermaLink="false">https://sdt.hameba.tw/?p=580</guid>
				<description><![CDATA[<p>在做不同分支repository合併結果出現: fatal: refusing to merge unrela &#8230; </p>
<p class="link-more"><a href="https://sdt.hameba.tw/580/" class="more-link">閱讀全文<span class="screen-reader-text">〈解決 git merge 不同分支出現 fatal: refusing to merge unrelated histories〉</span></a></p>
The post <a href="https://sdt.hameba.tw/580/">解決 git merge 不同分支出現 fatal: refusing to merge unrelated histories</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></description>
								<content:encoded><![CDATA[<p>在做不同分支repository合併結果出現:</p>
<p>fatal: refusing to merge unrelated histories.</p>
<p><span id="more-580"></span></p>
<p>明明是同一包分開做的結果出現無相關的提示..</p>
<p># <strong>從 git 2.9.0 開始預設行為不允許合併沒有共同祖先的分支。</strong></p>
<p>幸好只要加上 &#8211;allow-unrelated-histories 此參數即可以解決。</p><pre class="crayon-plain-tag">$ git merge master --allow-unrelated-histories</pre><p>&nbsp;</p>
<p>Reference</p>
<p><a href="https://stackoverflow.com/questions/37937984/git-refusing-to-merge-unrelated-histories-on-rebase" target="_blank" rel="noopener noreferrer">https://stackoverflow.com/questions/37937984/git-refusing-to-merge-unrelated-histories-on-rebase</a></p>The post <a href="https://sdt.hameba.tw/580/">解決 git merge 不同分支出現 fatal: refusing to merge unrelated histories</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></content:encoded>
							<wfw:commentRss>https://sdt.hameba.tw/580/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
		<item>
		<title>解決 Unable to access &#8216;git/attributes&#8217;</title>
		<link>https://sdt.hameba.tw/539/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e8%25a7%25a3%25e6%25b1%25ba-unable-to-access-git-attributes</link>
				<comments>https://sdt.hameba.tw/539/#respond</comments>
				<pubDate>Sat, 22 Feb 2020 17:18:06 +0000</pubDate>
		<dc:creator><![CDATA[Hsu Steven]]></dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">https://sdt.hameba.tw/?p=539</guid>
				<description><![CDATA[<p>在Server端部署code時git clone跑出： Unable to access &#8216;git &#8230; </p>
<p class="link-more"><a href="https://sdt.hameba.tw/539/" class="more-link">閱讀全文<span class="screen-reader-text">〈解決 Unable to access &#8216;git/attributes&#8217;〉</span></a></p>
The post <a href="https://sdt.hameba.tw/539/">解決 Unable to access ‘git/attributes’</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></description>
								<content:encoded><![CDATA[<p>在Server端部署code時git clone跑出：</p>
<p><strong>Unable to access &#8216;git/attributes&#8217;</strong><br />
<span id="more-539"></span></p>
<p>滿頭問號不知道為什麼，後來發現原因為.config檔案非當下使用者，</p><pre class="crayon-plain-tag">$ cd ~
$ ls -al

// 發現 .config 居然 user 是root....
$ sudo chown -R $(whoami) .config</pre><p>重設後，在git pull即可通過。</p>
<p>Reference</p>
<p><a href="https://stackoverflow.com/questions/27150926/unable-to-access-git-attributes" target="_blank" rel="noopener noreferrer">https://stackoverflow.com/questions/27150926/unable-to-access-git-attributes</a></p>The post <a href="https://sdt.hameba.tw/539/">解決 Unable to access ‘git/attributes’</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></content:encoded>
							<wfw:commentRss>https://sdt.hameba.tw/539/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
		<item>
		<title>Git local init push to remote branch</title>
		<link>https://sdt.hameba.tw/498/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=git-local-init-push-to-remote-branch</link>
				<comments>https://sdt.hameba.tw/498/#respond</comments>
				<pubDate>Mon, 27 Jan 2020 04:08:16 +0000</pubDate>
		<dc:creator><![CDATA[Hsu Steven]]></dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[git init]]></category>
		<category><![CDATA[git remote]]></category>
		<category><![CDATA[https]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">https://sdt.hameba.tw/?p=498</guid>
				<description><![CDATA[<p>有時開專案會先在本地端做測試，而開啟專案commit一些init資訊， 當你將本機端的 Git 加入到遠端的  &#8230; </p>
<p class="link-more"><a href="https://sdt.hameba.tw/498/" class="more-link">閱讀全文<span class="screen-reader-text">〈Git local init push to remote branch〉</span></a></p>
The post <a href="https://sdt.hameba.tw/498/">Git local init push to remote branch</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></description>
								<content:encoded><![CDATA[<p>有時開專案會先在本地端做測試，而開啟專案commit一些init資訊，</p>
<p>當你將本機端的 Git 加入到遠端的 repository 像是 GitHub …等，若之後你又另外建立新的的 repository 或是要將它搬移至其他遠端數據庫例如 GitLab。此時要刪除原本的 remote origin 該怎麼做？</p>
<p><span id="more-498"></span></p>
<p>可參考以下方式</p><pre class="crayon-plain-tag"># 專案引入git功能
$ git init

# commit 一些記錄點後
$ git add .
$ git commit -m "[INIT] Add react."
...
$ git commit -m "[INIT] Add react-router."
...
...

# 當測試完成後想要跟遠端專案做link的方式
# ssh
$ git remote add origin ssh://&lt;username&gt;@bitbucket.org/&lt;username&gt;/&lt;project&gt;

# or https
$ git remote add origin https://&lt;username&gt;@bitbucket.org/&lt;username&gt;/&lt;project&gt;

# 移除 remote
$ git remote remove origin

# 觀看目前git remote設定
$ git remote -v

# 設定local分支與遠端分支對齊
$ git branch --set-upstream-to=origin/master master

# 設定push資訊
$ git push -u
$ git push --set-upstream origin master</pre><p>&nbsp;</p>
<p>Reference</p>
<p><a href="https://stackoverflow.com/questions/42122191/git-initialize-and-push-local-repository-to-remote-not-found" target="_blank" rel="noopener noreferrer">https://stackoverflow.com/questions/42122191/git-initialize-and-push-local-repository-to-remote-not-found</a></p>
<p><a href="https://andy6804tw.github.io/2019/01/04/git-remove-remote/" target="_blank" rel="noopener noreferrer">https://andy6804tw.github.io/2019/01/04/git-remove-remote/</a></p>The post <a href="https://sdt.hameba.tw/498/">Git local init push to remote branch</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></content:encoded>
							<wfw:commentRss>https://sdt.hameba.tw/498/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
		<item>
		<title>Git 刪除分支</title>
		<link>https://sdt.hameba.tw/476/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=git-%25e5%2588%25aa%25e9%2599%25a4%25e5%2588%2586%25e6%2594%25af</link>
				<comments>https://sdt.hameba.tw/476/#respond</comments>
				<pubDate>Sun, 12 Jan 2020 17:40:56 +0000</pubDate>
		<dc:creator><![CDATA[Ted]]></dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">https://sdt.hameba.tw/?p=476</guid>
				<description><![CDATA[<p>每過一段時間，都要定時清理一下專案上分支的數量，不然時間一長，清理起來會很痛苦，所以這邊紀錄一下 Git 刪除 &#8230; </p>
<p class="link-more"><a href="https://sdt.hameba.tw/476/" class="more-link">閱讀全文<span class="screen-reader-text">〈Git 刪除分支〉</span></a></p>
The post <a href="https://sdt.hameba.tw/476/">Git 刪除分支</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></description>
								<content:encoded><![CDATA[<p>每過一段時間，都要定時清理一下專案上分支的數量，不然時間一長，清理起來會很痛苦，所以這邊紀錄一下 Git 刪除分支的語法。</p>
<p><span id="more-476"></span></p><pre class="crayon-plain-tag"># 刪除 local 的分支
git branch (-d | -D) &lt;branch name&gt;
e.g. git branch -d branch_test
e.g. git branch -D branch_test

# 刪除 remote 的分支
git push &lt;remote_name&gt; :&lt;branch name&gt;
e.g. git push origin :branch_test

git push &lt;remote_name&gt; --delete &lt;branch_name&gt;
e.g. git push origin --delete branch_test</pre><p>上述就是 Git 如何刪除分支的方法，不用懷疑，刪除 remote 分支就是那麼的簡單，只要在想刪除的 remote 分支前面加上 <code>:</code> 就可以了，注意，這邊 <code>:</code> 跟分支之間是沒有空格的喔。</p>
<p>參考資料:</p>
<p><a href="https://git-scm.com/docs/git-branch">https://git-scm.com/docs/git-branch</a></p>
<p><a href="https://stackoverflow.com/questions/2003505/how-do-i-delete-a-git-branch-locally-and-remotely">https://stackoverflow.com/questions/2003505/how-do-i-delete-a-git-branch-locally-and-remotely</a></p>
<div id="gtx-trans">
<div class="gtx-trans-icon"></div>
</div>The post <a href="https://sdt.hameba.tw/476/">Git 刪除分支</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></content:encoded>
							<wfw:commentRss>https://sdt.hameba.tw/476/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
		<item>
		<title>git diff 每行結尾出現^M如何解決</title>
		<link>https://sdt.hameba.tw/471/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=git-diff-%25e6%25af%258f%25e8%25a1%258c%25e7%25b5%2590%25e5%25b0%25be%25e5%2587%25ba%25e7%258f%25bem%25e5%25a6%2582%25e4%25bd%2595%25e8%25a7%25a3%25e6%25b1%25ba</link>
				<comments>https://sdt.hameba.tw/471/#respond</comments>
				<pubDate>Sun, 12 Jan 2020 06:05:53 +0000</pubDate>
		<dc:creator><![CDATA[Li Der]]></dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">https://sdt.hameba.tw/?p=471</guid>
				<description><![CDATA[<p>在 git diff 的時候，發現在每行結尾的地方居然出現了 ^M的符號， 原來是因為不同作業系統中，按下 e &#8230; </p>
<p class="link-more"><a href="https://sdt.hameba.tw/471/" class="more-link">閱讀全文<span class="screen-reader-text">〈git diff 每行結尾出現^M如何解決〉</span></a></p>
The post <a href="https://sdt.hameba.tw/471/">git diff 每行結尾出現^M如何解決</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></description>
								<content:encoded><![CDATA[<p>在 <kbd>git diff</kbd> 的時候，發現在每行結尾的地方居然出現了 ^M的符號，</p>
<p>原來是因為不同作業系統中，按下 enter(return) 結尾符號上的不同(LF、CRLF)，</p>
<p><span id="more-471"></span></p>
<p><img class="alignnone wp-image-472 size-full" src="https://sdt.hameba.tw/wp-content/uploads/2020/01/gitDiffM.png" alt="" width="598" height="220" srcset="https://sdt.hameba.tw/wp-content/uploads/2020/01/gitDiffM.png?v=1578806340 598w, https://sdt.hameba.tw/wp-content/uploads/2020/01/gitDiffM-300x110.png?v=1578806340 300w" sizes="(max-width: 598px) 100vw, 598px" /></p>
<p>當看到上方圖中出現^M的符號，表示檔案在每行結尾是有差異的。</p>
<p>這時候設定一下參數(core.autocrlf)，讓git更改每行結尾的方式。</p><pre class="crayon-plain-tag">$ git config --global core.autocrlf true</pre><p>以上設定是針對自己做處理，</p>
<p>如果專案是多人在進行的話，</p>
<p>建議在專案中加入 .gitattributes 來定義每行結尾的定義，</p>
<p>這樣就不會因為每台環境的不同而需要個別處理了。</p>
<p>參考資料：</p>
<p><a href="https://help.github.com/en/github/using-git/configuring-git-to-handle-line-endings#global-settings-for-line-endings">https://help.github.com/en/github/using-git/configuring-git-to-handle-line-endings#global-settings-for-line-endings</a></p>The post <a href="https://sdt.hameba.tw/471/">git diff 每行結尾出現^M如何解決</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></content:encoded>
							<wfw:commentRss>https://sdt.hameba.tw/471/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
		<item>
		<title>Git log 使用方法</title>
		<link>https://sdt.hameba.tw/361/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=git-log-%25e4%25bd%25bf%25e7%2594%25a8%25e6%2596%25b9%25e6%25b3%2595</link>
				<comments>https://sdt.hameba.tw/361/#respond</comments>
				<pubDate>Sun, 22 Dec 2019 12:27:57 +0000</pubDate>
		<dc:creator><![CDATA[Ted]]></dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">https://sdt.hameba.tw/?p=361</guid>
				<description><![CDATA[<p>常常過了一段時間之後，再回去看前面的代碼，都會忘記自己當初為什麼會寫這些東西，亦或是要查看別人寫的這段代碼有什 &#8230; </p>
<p class="link-more"><a href="https://sdt.hameba.tw/361/" class="more-link">閱讀全文<span class="screen-reader-text">〈Git log 使用方法〉</span></a></p>
The post <a href="https://sdt.hameba.tw/361/">Git log 使用方法</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></description>
								<content:encoded><![CDATA[<p>常常過了一段時間之後，再回去看前面的代碼，都會忘記自己當初為什麼會寫這些東西，亦或是要查看別人寫的這段代碼有什麼用意，這時候就會用到 git log 這個指令啦。</p><pre class="crayon-plain-tag"># git log 
# 會顯示以下訊息

commit &lt;commit id&gt;
Author: &lt;user name&gt; &lt;user email&gt;
Date:   Fri Apr 26 23:34:27 2019 +0800

    &lt;commit message&gt;</pre><p>如果只想要看到 commit message 呢？</p><pre class="crayon-plain-tag"># 使用 --oneline 參數， Ex: git log --oneline
# 會顯示以下訊息
 
&lt;commit id&gt; &lt;commit message&gt;
471d76d     test1
700206a     test2
d637045     test3</pre><p><span id="more-361"></span></p>
<p>在更進階一點，如果想要在 commit 裡面找特定的關鍵字呢？</p><pre class="crayon-plain-tag"># 使用 --grep="&lt;msg&gt;"， Ex: git log --oneline --grep="1"
# 承接 --oneline 參數使用，方便對照

&lt;commit id&gt; &lt;commit message&gt; 
471d76d     test1</pre><p>&nbsp;</p>
<p>Reference : <a href="https://git-scm.com/book/zh-tw/v2/Git-%E5%9F%BA%E7%A4%8E-%E6%AA%A2%E8%A6%96%E6%8F%90%E4%BA%A4%E7%9A%84%E6%AD%B7%E5%8F%B2%E8%A8%98%E9%8C%84">https://git-scm.com/book/zh-tw/v2/Git-%E5%9F%BA%E7%A4%8E-%E6%AA%A2%E8%A6%96%E6%8F%90%E4%BA%A4%E7%9A%84%E6%AD%B7%E5%8F%B2%E8%A8%98%E9%8C%84</a></p>
<div id="gtx-trans">
<div class="gtx-trans-icon"></div>
</div>The post <a href="https://sdt.hameba.tw/361/">Git log 使用方法</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></content:encoded>
							<wfw:commentRss>https://sdt.hameba.tw/361/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
		<item>
		<title>解決 .gitignore 規則沒有反應</title>
		<link>https://sdt.hameba.tw/317/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e8%25a7%25a3%25e6%25b1%25ba-gitignore%25e8%25a6%258f%25e5%2589%2587%25e6%25b2%2592%25e6%259c%2589%25e5%258f%258d%25e6%2587%2589</link>
				<comments>https://sdt.hameba.tw/317/#respond</comments>
				<pubDate>Mon, 09 Dec 2019 17:19:56 +0000</pubDate>
		<dc:creator><![CDATA[Li Der]]></dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[gitignore]]></category>

		<guid isPermaLink="false">https://sdt.hameba.tw/?p=317</guid>
				<description><![CDATA[<p>不小心把不需要追蹤的檔案上傳到 Git， 後來才到 .gitignore 把檔案加入， 這時候 Git 還是會 &#8230; </p>
<p class="link-more"><a href="https://sdt.hameba.tw/317/" class="more-link">閱讀全文<span class="screen-reader-text">〈解決 .gitignore 規則沒有反應〉</span></a></p>
The post <a href="https://sdt.hameba.tw/317/">解決 .gitignore 規則沒有反應</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></description>
								<content:encoded><![CDATA[<p>不小心把不需要追蹤的檔案上傳到 Git，</p>
<p>後來才到 .gitignore 把檔案加入，</p>
<p>這時候 Git 還是會追蹤的呢。</p>
<p><span id="more-317"></span></p>
<p>首先，我們要先將檔案從 Git 暫存區移除</p><pre class="crayon-plain-tag">git rm --cached &lt;file&gt;</pre><p>接下來就會發現檔案會按照規則排除了！</p>
<p>&nbsp;</p>
<p>參考資料：<br />
<a href="https://shiyousan.com/post/636470505667009340">https://shiyousan.com/post/636470505667009340</a></p>The post <a href="https://sdt.hameba.tw/317/">解決 .gitignore 規則沒有反應</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></content:encoded>
							<wfw:commentRss>https://sdt.hameba.tw/317/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
	</channel>
</rss>
