計算機科学実験及び演習のための Git / Git for Hardware and Software Laboratory Project

計算機科学実験及び演習のための Git / Git for Hardware and Software Laboratory Project

D984cd543d2abef28596cc5cfe82240c?s=128

Yusuke Miyazaki

April 14, 2016
Tweet

Transcript

  1. ܭࢉثՊֶ࣮ݧٴͼԋश :VTVLF.JZB[BLJ !૯߹ݚڀ߸ؗ ܭࢉػՊֶ࣮ݧٴͼԋशͷ
 ͨΊͷ(JU

  2. ͜Μͳ͜ͱ͋Γ·ͤΜ͔ w ʮίʔυΛॻ͍͍ͯͨΒΑ͘Θ͔Βͳ͘ͳͬͨ ͷͰࡢ೔ॻ͍ͨͱ͜Ζ·Ͱ໭Γ͍ͨʯ w ʮͲ͜Λฤूͨ͠ͷ͔෼͔Βͳ͘ͳͬͨʯ w ʮ՝୊Λఏग़ͨ͠λΠϛϯάͷίʔυΛ࢒ͯ͠ ͓͖͍ͨʯ

  3. (JUΛ࢖͏ͱʜ w ࣍ͷΑ͏ͳ͜ͱ͕Ͱ͖·͢ w ػೳΛͭ௥Ճͨ͠௚ޙͷঢ়ଶΛอଘ w ՝୊Λఏग़ͨ͠λΠϛϯάͷঢ়ଶΛอଘ w લճͷঢ়ଶ͔Βฤूͨ͠಺༰ͷࠩ෼ΛӾཡ

  4. (JUͱ͸ w ෼ࢄܕόʔδϣϯ؅ཧγεςϜ 7$4  w -JOVYΧʔωϧͷόʔδϣϯ؅ཧͷͨΊʹ
 -JOVT5PSWBMETࢯʹΑͬͯ։ൃ w ݱࡏͷϝϯςφᖛ໺७ࢯ

  5. όʔδϣϯ؅ཧγεςϜ w ϑΝΠϧ ιʔείʔυͳͲ ͷมߋཤྺΛ؅ཧ ͢ΔγεςϜ w ػೳΛ௥Ճ͢Δͨͼʹͦͷঢ়ଶΛอଘͰ͖Δ w όάΛ࢓ࠐΜͰ͠·ͬͨ৔߹͸Ҏલͷঢ়ଶʹ໭

    Δ͜ͱ͕Ͱ͖Δ w ͋Δఔ౓ͷن໛ͷιϑτ΢ΣΞͰ͸΄΅ඞਢ
  6. (JUͷΠϝʔδ ίϛοτ
 ϑΝΠϧͷมߋ಺༰΍
 ϝοηʔδΛؚΉ w ίϛοτ͕༗޲ඇ८ճάϥϑ %"( Λ੒͢ ϒϥϯνɾϚʔδ ཤྺΛ෼ذͯ͠౷߹Ͱ͖Δ


    ࠓճ͸આ໌͠ͳ͍
  7. ࡞ۀͷྲྀΕ 8PSLJOH ࡞ۀσΟϨΫτϦ 4UBHJOH )JTUPSZ ίϛοτ  OFX QBSTFSSLU UFTUSLU

    NPEJpFE TZOUBYSLU 8PSLJOH%JSFDUPSZʹϑΝΠϧΛ௥Ճɾฤू
  8. ࡞ۀͷྲྀΕ 8PSLJOH ࡞ۀσΟϨΫτϦ 4UBHJOH )JTUPSZ ίϛοτ  ίϛοτ͍ͨ͠ϑΝΠϧΛTUBHJOHʹ
 HJUBEEpMFpMF OFX

    QBSTFSSLU UFTUSLU NPEJpFE TZOUBYSLU OFX QBSTFSSLU NPEJpFE TZOUBYSLU
  9. ࡞ۀͷྲྀΕ 8PSLJOH ࡞ۀσΟϨΫτϦ 4UBHJOH )JTUPSZ ίϛοτ  4UBHJOHͷ಺༰Λίϛοτ ཤྺʹొ࿥ 


    HJUDPNNJUNNFTTBHF OFX QBSTFSSLU UFTUSLU NPEJpFE TZOUBYSLU OFX QBSTFSSLU NPEJpFE TZOUBYSLU NFTTBHF IBTI OFX QBSTFSSLU NPEJpFE TZOUBYSLU
  10. ϦϙδτϦͷ࡞੒ w όʔδϣϯ؅ཧΛ࢝ΊΔͨΊʹ ཤྺΛ֨ೲ͢Δ (JUϦϙδτϦΛ࡞੒͢Δ w ͸͡ΊʹҰ౓͚ͩߦ͑͹ w ϓϩδΣΫτͷϧʔτσΟϨΫτϦͰ
 $

    git init
  11. ঢ়ଶͷ֬ೝ w ݱࡏͷ(JUϦϙδτϦͷঢ়ଶΛ֬ೝ͢Δʹ͸
 $ git status w 8PSLJOH%JSͰ௥Ճɾมߋ͞Εͨ಺༰΍
 4UBHJOHʹ௥Ճ͞Εͨ಺༰͕දࣔ͞ΕΔ w

    ঢ়گ͕Α͘Θ͔Βͳ͘ͳͬͨΒͱΓ͋͑ͣ TUBUVTΛݟΔบΛ͚ͭ·͠ΐ͏
  12. ίϛοτ w ػೳͷ௥Ճ΍όάͷमਖ਼ͳͲ͖Γͷྑ͍࣌఺Ͱ ίϛοτ͠ঢ়ଶΛอଘ͓ͯ͘͠ w ·ͣ৽͘͠όʔδϣϯ؅ཧԼʹஔ͘ϑΝΠϧ΍ มߋͨ͠ϑΝΠϧΛ4UBHJOHʹ௥Ճ͢Δ
 $ git add

    <file1> <file2> …
  13. ίϛοτ w 4UBHJOHͷ಺༰Λίϛοτͯ͠ཤྺʹొ࿥͢Δ
 $ git commit -m "<commit message>" w

    ίϛοτ࣌ʹ͸ϝοηʔδΛ෇Ճ͢Δ w มߋ಺༰Λॻ͍͓ͯ͘ͱޙͰ෼͔Γ΍͍͢ w ྫύʔαʔΛ࣮૷ w ྫҙຯղੳͰʙʙʙʹͳΔόάΛमਖ਼
  14. ཤྺͷӾཡ w ཤྺΛӾཡ͢Δ$ git log w ίϛοτͷҰཡ͕ϋογϡɾϝοηʔδɾ೔࣌ͳͲ ͱͱ΋ʹදࣔ͞ΕΔ w ͦΕͧΕͷίϛοτ͸ϋογϡ

    4)" Ͱ
 ҰҙʹಛఆͰ͖Δ
 ྫ5a00b5712a039bfea1e8055206ab697e3081247d w ΦϓγϣϯΛ෇Ճ͢Δͱ΋ͬͱ৭ʑݟΕΔ
  15. ཤྺͷӾཡ w ಛఆͷίϛοτͷมߋ಺༰ΛݟΔ
 $ git show <commit>

  16. ࠩ෼ͷӾཡ w ࠷ޙͷίϛοτͱ8PSLJOHͷࠩ෼
 $ git diff w ࠷ޙͷίϛοτͱ4UBHJOHͷࠩ෼
 $ git

    diff --cached w ͋Δίϛοτ"ͱ͋Δίϛοτ#ͷࠩ෼
 $ git diff <commit A>...<commit B>
  17. ࠷ޙͷίϛοτ·Ͱ໭Δ w pMFPSEJSΛ࠷ޙͷίϛοτͷঢ়ଶʹ໭͢
 $ git checkout <file or dir>

  18. ίϛοτͷ࡟আ w ͋Δίϛοτ·Ͱ࡟আ͢Δ
 8PSLJOH%JS͸ͦͷ·· 
 $ git reset --soft w

    ͋Δίϛοτ·Ͱ࡟আ͢Δ
 8PSLJOH%JS΋ॻ͖׵͑Δ 
 $ git reset --hard
  19. • man git / git help <subcommand> w IUUQTHJUTDNDPNEPD w

    IUUQTUSBJOJOHHJUIVCDPNSFTPVSDFT ͞Βʹৄ͘͠