Upgrade to Pro — share decks privately, control downloads, hide ads and more …

你知道 Git 是怎麼一回事嗎

高見龍
August 10, 2017

你知道 Git 是怎麼一回事嗎

這是在今年 ModernWeb 研討會上分享的講題。這個主題基本上算是一個科普等級的分享,主要是介紹關於 Git 一些你可能知道,也可能還不知道,或是以為已經知道但其實是不知道的東西。

高見龍

August 10, 2017
Tweet

More Decks by 高見龍

Other Decks in Technology

Transcript

  1. 䔩㨍 2016/2/8 A B C 䔩㨍 2016/2/10 D E A

    B C 䔩㨍 2016/8/22 A B C D E F G 䔩㨍 2016/5/8 A B C D E
  2. 䔩㨍 2016/2/8 A B C 䔩㨍 2016/2/10 D E A

    B C 䔩㨍 2016/8/22 A B C D E F G 䔩㨍 2016/5/8 A B C D E E D
  3. 䔩㨍 2016/2/8 A B C 䔩㨍 2016/2/10 D E A

    B C 䔩㨍 2016/8/22 A B C D E F G 䔩㨍 2016/5/8 A B C D E E D B C
  4. 䔩㨍 2016/2/8 A B C 䔩㨍 2016/2/10 D E A

    B C 䔩㨍 2016/8/22 A B C D E F G 䔩㨍 2016/5/8 A B C D E E D B C F G
  5. 䔩㨍 2016/2/8 A B C 䔩㨍 2016/2/10 D E A

    B C 䔩㨍 2016/8/22 A B C D E F G 䔩㨍 2016/5/8 A B C D E
  6. 䔩㨍 2016/2/8 A B C 䔩㨍 2016/2/10 D E A

    B C 䔩㨍 2016/8/22 A B C D E F G 䔩㨍 2016/5/8 A B C D E E D
  7. 䔩㨍 2016/2/8 A B C 䔩㨍 2016/2/10 D E A

    B C 䔩㨍 2016/8/22 A B C D E F G 䔩㨍 2016/5/8 A B C D E E D B C
  8. 䔩㨍 2016/2/8 A B C 䔩㨍 2016/2/10 D E A

    B C 䔩㨍 2016/8/22 A B C D E F G 䔩㨍 2016/5/8 A B C D E E D B C F G
  9. $ git log commit 657fce783a23e26721ec4f778b9e0e108253e92d (HEAD -> master) Author: Eddie

    Kao <[email protected]> Date: Wed Aug 2 16:53:43 2017 +0800 add container commit abb4f43814af7bcf47afa9b779aaba63599e562b Author: Eddie Kao <[email protected]> Date: Wed Aug 2 16:49:49 2017 +0800 update index page commit cef6e4017eb1a16a7bb3434f12d9008ff83a821a Author: Eddie Kao <[email protected]> Date: Wed Aug 2 03:02:37 2017 +0800 create index page ⼒㤐聅ⅼ䧬群≧ 瓞Ⅳ䮝䥥⎃⇺⡇
  10. $ irb >> require "digest/sha1" => true >> content =

    "Hello, 5xRuby" => "Hello, 5xRuby" 戙⑆䥥⑈⺚
  11. $ irb >> require "digest/sha1" => true >> content =

    "Hello, 5xRuby" => "Hello, 5xRuby" >> input = "blob #{content.length}\0#{content}" => "blob 13\u0000Hello, 5xRuby" ⨉聅寂▁㡺
  12. $ irb >> require "digest/sha1" => true >> content =

    "Hello, 5xRuby" => "Hello, 5xRuby" >> input = "blob #{content.length}\0#{content}" => "blob 13\u0000Hello, 5xRuby" >> Digest::SHA1.hexdigest(input) => "4135fc4add3332e25ab3cd5acabe1bd9ea0450fb" 乸ⓛ丵礌
  13. $ git commit -m "init commit" fa6556 1e06da 635706 8cfc26

    㓲㤐⃡⋬ VTGG䕊⇗ 㓲⅀㤐 VTGG䕊⇗
  14. $ git commit -m "init commit" fa6556 1e06da 635706 8cfc26

    e076c8 㓲㤐⃡⋬ VTGG䕊⇗ 㓲⅀㤐 VTGG䕊⇗ 㓲㤐 EQOOKV䕊⇗
  15. $ git commit -m "init commit" fa6556 1e06da 635706 8cfc26

    e076c8 㓲㤐⃡⋬ VTGG䕊⇗ 㓲⅀㤐 VTGG䕊⇗ 㓲㤐 EQOOKV䕊⇗  master HEAD
  16. $ echo "this is a book" >> index.html fa6556 1e06da

    635706 8cfc26 e076c8  master HEAD
  17. $ echo "this is a book" >> index.html fa6556 1e06da

    635706 8cfc26 e076c8 OQFKHKGF 䖡㐬  master HEAD
  18. $ git commit -m "update index.html" fa6556 1e06da 635706 8cfc26

    e076c8 7ffd42 afa760 EQPHKI㽳㧪 䡑▶  master HEAD
  19. $ git commit -m "update index.html" fa6556 1e06da 635706 8cfc26

    e076c8 7ffd42 35c42e afa760  master HEAD
  20. $ git commit -m "update index.html" fa6556 1e06da 635706 8cfc26

    e076c8 7ffd42 35c42e afa760  master HEAD
  21. $ git commit -m "update index.html" fa6556 1e06da 635706 8cfc26

    e076c8 7ffd42 35c42e afa760  master HEAD
  22. fa6556 1e06da 635706 8cfc26 e076c8 7ffd42 35c42e afa760 $ echo

    "super-secret-password" > key.txt WPVTCEMGF 䖡㐬  master HEAD
  23. $ git add key.txt fa6556 1e06da 635706 8cfc26 e076c8 7ffd42

    35c42e afa760 ⃮㧤䠃䠀㢑䥥 $NQD䕊⇗  master HEAD
  24. fa6556 1e06da 635706 8cfc26 e076c8 7ffd42 35c42e afa760 $ git

    commit -m "add secret key"  master HEAD
  25. fa6556 1e06da 635706 8cfc26 e076c8 7ffd42 35c42e afa760 9e6fd0 $

    git commit -m "add secret key"  master HEAD
  26. fa6556 1e06da 635706 8cfc26 e076c8 7ffd42 35c42e afa760 9e6fd0 $

    git commit -m "add secret key" FCVCDCUG[ON 㽳㧪䡑▶  master HEAD
  27. fa6556 1e06da 635706 8cfc26 e076c8 7ffd42 35c42e afa760 9e6fd0 $

    git commit -m "add secret key" EQPHKI㽳㧪 䡑▶  master HEAD
  28. fa6556 1e06da 635706 8cfc26 e076c8 7ffd42 35c42e afa760 b43d89 9e6fd0

    $ git commit -m "add secret key"  master HEAD
  29. fa6556 1e06da 635706 8cfc26 e076c8 7ffd42 35c42e afa760 b43d89 9e6fd0

    $ git commit -m "add secret key"  master HEAD
  30. fa6556 1e06da 635706 8cfc26 e076c8 7ffd42 35c42e afa760 b43d89 9e6fd0

    $ git commit -m "add secret key"  master HEAD
  31. $ git checkout e076c8 fa6556 1e06da 635706 8cfc26 e076c8 7ffd42

    35c42e afa760 b43d89 9e6fd0 fa6556 1e06da 635706 8cfc26 e076c8  master HEAD
  32. $ git checkout 35c42e fa6556 1e06da 635706 8cfc26 e076c8 7ffd42

    35c42e afa760 b43d89 9e6fd0 1e06da 8cfc26 7ffd42 35c42e afa760  master HEAD
  33. $ git checkout b43d89 fa6556 1e06da 635706 8cfc26 e076c8 7ffd42

    35c42e afa760 b43d89 9e6fd0 1e06da 8cfc26 7ffd42 b43d89 9e6fd0  master HEAD
  34. cat master $ git commit -m "..." dog HEAD e076c8

    35c42e b43d89 f17acb 76ccce 981ad3
  35. cat master $ git commit -m "..." dog HEAD e076c8

    35c42e b43d89 f17acb 76ccce 981ad3
  36. cat master $ git merge cat dog HEAD e076c8 35c42e

    b43d89 f17acb 76ccce 981ad3 e076c8
  37. cat master $ git merge cat dog HEAD e076c8 35c42e

    b43d89 f17acb 76ccce 981ad3 e076c8
  38. $ git reset HEAD^ --hard cat master dog HEAD e076c8

    35c42e b43d89 f17acb 76ccce 981ad3 e076c8
  39. $ git reset HEAD^ --hard cat master dog HEAD e076c8

    35c42e b43d89 f17acb 76ccce 981ad3
  40. dog master $ git merge dog cat HEAD e076c8 35c42e

    b43d89 f17acb 76ccce 981ad3 e076c8
  41. dog master $ git merge dog cat HEAD e076c8 35c42e

    b43d89 f17acb 76ccce 981ad3 e076c8
  42. cat master $ git merge cat e076c8 35c42e b43d89 f17acb

    76ccce 981ad3 e076c8 dog HEAD ㋌截㴂ㇰ
 HCUJHQTYCTF
  43. dog cat $ git merge dog e076c8 35c42e b43d89 f17acb

    76ccce 981ad3 e076c8 master HEAD
  44. dog cat $ git merge dog e076c8 35c42e b43d89 f17acb

    76ccce 981ad3 e076c8 master HEAD
  45. dog cat $ git merge dog e076c8 35c42e b43d89 f17acb

    76ccce 981ad3 e076c8 master HEAD ㋌截㴂ㇰ
 HCUJHQTYCTF
  46. f17acb b43d89 35c42e 76ccce 981ad3 dog master b43d89 f17acb $

    git rebase dog c871e3 ab12cd cat HEAD 䠺⨉聅肰 粹圸完⦿㠗
  47.  䫆聼 )KV 寂䥥  䴏䕊⇗  䫆聼↡熝㤐 5*# 

    䫆聼↡熝㤐 %QOOKV  䫆聼 %QOOKV 䥥磢⋺䥝䠀↡熝Ⅼ
  48.  䫆聼 )KV 寂䥥  䴏䕊⇗  䫆聼↡熝㤐 5*# 

    䫆聼↡熝㤐 %QOOKV  䫆聼 %QOOKV 䥥磢⋺䥝䠀↡熝Ⅼ  䫆聼↡熝㤐ⓧ㠐
  49.  䫆聼 )KV 寂䥥  䴏䕊⇗  䫆聼↡熝㤐 5*# 

    䫆聼↡熝㤐 %QOOKV  䫆聼 %QOOKV 䥥磢⋺䥝䠀↡熝Ⅼ  䫆聼↡熝㤐ⓧ㠐  䫆聼⛩≖ⓧ㠐䥥磢⋺䥝䠀↡熝Ⅼ
  50.  䫆聼 )KV 寂䥥  䴏䕊⇗  䫆聼↡熝㤐 5*# 

    䫆聼↡熝㤐 %QOOKV  䫆聼 %QOOKV 䥥磢⋺䥝䠀↡熝Ⅼ  䫆聼↡熝㤐ⓧ㠐  䫆聼⛩≖ⓧ㠐䥥磢⋺䥝䠀↡熝Ⅼ  䫆聼㩒屠聜 )KV苌缙䫮肪⃮Ⰻ⺚㣴