Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

為你自己學 Git #1

Open
x03177 opened this issue May 25, 2019 · 0 comments
Open

為你自己學 Git #1

x03177 opened this issue May 25, 2019 · 0 comments

Comments

@x03177
Copy link
Owner

x03177 commented May 25, 2019

高雄場 - 為你自己學 Git,這是第二次來聽高見龍大大講解 Git,第一次是在新崛江附近某大樓,只記得每次 commit 後會有一個 SHA-1 值,不重複的 40 個十六進位數被拿來區分每一次 commit 的差異,硬要重複就要另外暴力讓他重複;分支是便利貼,可以挪來挪去;不要擔心 Git 上的資料不見,那很難。那時候剛學網頁沒多久,聽得是一臉矇 ( º﹃º )
當天起床的時候看到六角洧杰校長的貼文分享,立刻手刀報名飛奔~

小簡介

  • Git 在 2005 年被 Linus 在 10 天內做出來。易學難精的技能。
  • 一個 commit 對應一個 SHA-1 值,每個 commit 視為一個節點。這次主要說明分支和 Resrt。

分支

  • 建立分支是某次 commit 的結果,不是複製 master 的歷程。分支是一個標示,而一個 commit 可以有多個分支標示。
  • Head,表示現在位置。最近在玩 swtich 的煮過頭,Head 就像關卡地圖的巴士,顯示你在哪一關的感覺~
  • 未修改的 commit 無效。
  • 單線合併 fast-forward(快轉),Git 預設不會產生新的 merge commit;如果不想要快轉就使用不要快轉 --no--ff,Git 會產生一個新的 commit 給你。

Reset

  • Reset 字義上像 go to 或 become
  • git reset 搭配三種參數
    --mixed,是預設參數。拆 Commit 後分開的檔案會留在工作目錄,但不會留在暫存區。
    --soft,拆 Commit 後分開的檔案會留在工作目錄和暫存區。
    --hard,通通丟掉。
  • git -reflog,紀錄 head 的移動歷程,可以重新貼上便利貼的小幫手。
  • reset 上一步,有相對位置和絕對位置。
位置 說明
絕對位置 直接輸入
相對位置^ 這是上一步
相對位置^^^^^ 這是上五步,開嘲笑臉σ`∀´)σ
相對位置~5 這也是上五步

其他小撇步

  • 被突然召喚做別的事時,把現在進度存個檔 git stash
  • commit 可以做個 tag,但這個 tag 不會隨分支移動

對 Git 又 wow 了一次,工作目錄和暫存區的部分要再熟悉一下,結束的時候有獲得當日簡報電子檔,有概念後在實際上還是有很多狀況題,有列舉狀況題可以練習。ヽ(*´∀`)ノ

20190310

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant