@@ -1484,7 +1484,7 @@ v2 分支中的 log 如下,我想要它的 553587b - add f.py這個 commit
14841484
14851485假設我 commit history 為 A1 -> A2 -> A3 -> A4 -> A5 -> A6
14861486
1487- 我現在想要回 A4 這個 commit , 這時候我就可以使用 git revert !!
1487+ 我現在想要回 A4 這個 commit , 這時候我就可以使用 git revert !!
14881488
14891489先 revert A6
14901490
@@ -1504,10 +1504,16 @@ A1 -> A2 -> A3 -> A4 -> A5 -> A6 -> A6_revert -> A5_revert
15041504
15051505這時候,其實你的 commit 就是在 A4 這個位置 。
15061506
1507- 使用 git revert 的好處,就是可以保留 commit history , 萬一你又後悔了,
1507+ 使用 git revert 的好處,就是可以保留 commit history, 萬一你又後悔了,
15081508
15091509也可以在 revert 回去。
15101510
1511+ 如果你想要 revert 最新的 commit, 只需要使用 HEAD
1512+
1513+ ``` cmd
1514+ git revert HEAD
1515+ ```
1516+
15111517## 解決衝突
15121518
15131519在進行合併的時候,有時候會顯示出 ** 衝突conflicts** ,這時候就必須手動解決衝突後再送出。
@@ -1817,6 +1823,81 @@ git grep "hello"
18171823
18181824其他更詳細的介紹,請參考 [ https://git-scm.com/docs/git-grep ] ( https://git-scm.com/docs/git-grep )
18191825
1826+ ## git clean
1827+
1828+ 刪除未被追蹤的檔案,
1829+
1830+ ` git clean -n `
1831+
1832+ ` -n, --dry-run ` Don’t actually remove anything, just show what would be done
1833+
1834+ 這個指定是告訴你會刪除哪些資料, 不會真的刪除.
1835+
1836+ 範例如下,
1837+
1838+ ``` cmd
1839+ ❯ git status
1840+ On branch master
1841+
1842+ No commits yet
1843+
1844+ Untracked files:
1845+ (use "git add <file>..." to include in what will be committed)
1846+ test.py
1847+
1848+ nothing added to commit but untracked files present (use "git add" to track)
1849+
1850+ ❯ git clean -n
1851+ Would remove test.py
1852+ ```
1853+
1854+ 如果你執行以下的指令, 就會真的刪除,
1855+
1856+ ` git clean -df `
1857+
1858+ 詳細說明可使用 ` git clean --help ` 觀看,
1859+
1860+ 範例如下,
1861+
1862+ ``` cmd
1863+ ❯ git status
1864+ On branch master
1865+
1866+ No commits yet
1867+
1868+ Untracked files:
1869+ (use "git add <file>..." to include in what will be committed)
1870+ test.py
1871+
1872+ nothing added to commit but untracked files present (use "git add" to track)
1873+
1874+ ❯ git clean -df
1875+ Removing test.py
1876+
1877+ ❯ git status
1878+ On branch master
1879+
1880+ No commits yet
1881+
1882+ nothing to commit (create/copy files and use "git add" to track)
1883+ ```
1884+
1885+ 還記得前面介紹的 ` git reset ` 指令嗎, 基本上它可以搭配 ` git clean ` 一起使用,
1886+
1887+ ` git clean ` 影響沒有被 track 的檔案
1888+
1889+ ` git reset ` 影響有被 track 的檔案
1890+
1891+ 結合以上, 可以回到一個指定的 commit 乾淨的狀態,
1892+
1893+ ``` cmd
1894+ git reset --hard HEAD
1895+ git clean -df
1896+ git status
1897+ ```
1898+
1899+ 建議大家自己操作一下.
1900+
18201901## git Submodule
18211902
18221903由於這個內容稍微比較多,所以我另外寫了一篇,
@@ -1936,6 +2017,10 @@ git config --global alias.br branch
19362017git config --global alias.ck checkout
19372018```
19382019
2020+ ``` cmd
2021+ git config --global alias.sw switch
2022+ ```
2023+
19392024``` cmd
19402025git config --global alias.cm commit
19412026```
@@ -2108,7 +2193,7 @@ git remote set-url origin git@blue.github.com:blue-rubiks/t11.git
21082193
21092194* [ Youtube Tutorial - github PR (Pull Request) 教學] ( https://youtu.be/bXOdD-bKfkA ) - [ 文章快速連結] ( https://github.com/twtrubiks/Git-Tutorials/tree/master/pr-tutorial#github-pr-pull-request-%E6%95%99%E5%AD%B8 )
21102195
2111- * [ Youtube Tutorial - github CLI PR 教學] ( https://youtu.be/AD8X11lq3gQ ) - [ 文章快速連結] ( https://github.com/twtrubiks/Git-Tutorials/tree/master/pr-tutorial#github-cli-pr-%E6%95%99%E5%AD%B8 )
2196+ * [ Youtube Tutorial - github CLI PR 教學 - gh ] ( https://youtu.be/AD8X11lq3gQ ) - [ 文章快速連結] ( https://github.com/twtrubiks/Git-Tutorials/tree/master/pr-tutorial#github-cli-pr-%E6%95%99%E5%AD%B8 )
21122197
21132198[ PR (Pull Request) 教學] ( https://github.com/twtrubiks/Git-Tutorials/tree/master/pr-tutorial )
21142199
0 commit comments