File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -1525,6 +1525,52 @@ git grep "hello"
15251525
15261526![ alt tag] ( https://i.imgur.com/W3cxk9r.jpg )
15271527
1528+ ### .gitignore (Temporarily and Permanently)
1529+
1530+ 主要分 暫時(Temporarily) 和 永久(Permanently) 的ignore,
1531+
1532+ * Temporarily ignore
1533+
1534+ 適合使用在 settings 的檔案,有時候我們在開發的時候,都會有自己的設定,
1535+
1536+ 但這個設定未必是大家都需要的,這時候就可以暫時先忽略這個檔案的改變。
1537+
1538+ 暫時忽略某個檔案
1539+
1540+ ``` cmd
1541+ git update-index --skip-worktree <file>
1542+ ```
1543+
1544+ 恢復(Resume)暫時忽略某個檔案
1545+
1546+ ``` cmd
1547+ git update-index --no-skip-worktree <file>
1548+ ```
1549+
1550+ * Permanently ignore
1551+
1552+ 這邊補充一個情境,假設今天 file 這個檔案已經被 commit 到 git 中了,
1553+
1554+ 但是我想把他加入 .gitignore,這樣該怎麼辦:question :
1555+
1556+ 如果你在 .gitignore 中加入 file,你會發現還是沒有被 ignore:confused :
1557+
1558+ ![ alt tag] ( https://i.imgur.com/o922paa.png )
1559+
1560+ 這時候,正確的做法應該是要先執行已下指令,
1561+
1562+ ``` cmd
1563+ git rm --cached <file>
1564+ ```
1565+
1566+ 執行完後再 commit 即可 ( 檔案不會從系統上刪除,只是要更新 git 的 index 而已 )
1567+
1568+ ![ alt tag] ( https://i.imgur.com/RJZ08OQ.png )
1569+
1570+ 這時候可以再嘗試更新 file 的內容,你會發現它成功被 ignore 了:smile :
1571+
1572+ ### git alias
1573+
15281574有時候常常手殘 key 錯指令或是記不起來
15291575
15301576如果我們打 git st 就表示 git status 那該有多棒!!!
You can’t perform that action at this time.
0 commit comments