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

すごいGit楽しく学ぼう

 すごいGit楽しく学ぼう

MIXI ENGINEERS

May 12, 2015
Tweet

More Decks by MIXI ENGINEERS

Other Decks in Programming

Transcript

  1. ࢖ͬͯΈΑ͏ʂͷͦͷલʹ $ git config --global user.name "Amy Mikushi" $ git

    config --global user.email "[email protected]" Gitʹࣗݾ঺հ ͜͜Ͱొ࿥ͨ͠৘ใ͕(JUͷૢ࡞ʹ͍ͭͯճΔʂ
  2. ͸͡ΊͯΈΑ͏ $ mkdir books $ cd books $ git init

    GitϦϙδτϦΛ࡞੒͠Α͏ ϦϙδτϦ͸ɺόʔδϣϯ؅ཧ͢ΔͨΊͷ ஷଂݿͷ͜ͱͰ͢
  3. ڞಉ։ൃ͜ͱ͸͡Ί $ cd .. $ git clone [email protected]:<your account>/books.git alt_books

    GitΛ࢖͏͜ͱͰෳ਺ਓͰ͔ΜͨΜʹ։ൃͰ͖·͢ʂ ࠓ͔Βผਓ ͷؾ࣋ͪ ʹͳͬͯମݧͯ͠Έ·͠ΐ͏ ·ͣ͸ϦϞʔτϦϙδτϦΛखݩʹऔΓࠐΈ·͢ alt_booksͱ͍͏໊લͰϦϙδτϦΛෳ੡(clone)Ͱ͖ ͨʂ
  4. ڞಉ։ൃ͜ͱ͸͡Ί $ cd alt_books $ vim Crusoe.txt $ git add

    Crusoe.txt $ git commit $ git push Ͱ͸ɺalt_booksͰ࡞ۀΛ͍͖ͯ͠·͠ΐ͏ pushͨ͠ΒɺGitHubͰ֬ೝͯ͠ΈΑ͏ʂ
  5. ݩʹ໭͢ $ vim Sherlock.txt $ git checkout -- Sherlock.txt ͜ΕͰ޷͖ͳ͚ͩBEEΛͨ͠ΓɺBEEΛऔΓফͨ͠ΓͰ

    ͖·͢ ࣍͸ϑΝΠϧࣗମΛલճͷίϛοτঢ়ଶʹ໭͢ํ๏Ͱ͢ ίϛοτͯ͠ͳ͍มߋ͸ফ͑ͪΌͬͯݩʹ໭ͤͳ͍ʂ
  6. ϒϥϯν $ git branch new     

    ৽͍͠ͷ͕ग़དྷͨʂ ৽ͨͳnewͱ͍͏໊લͷϒϥϯνΛ࡞੒ͯ͠ΈΔ
  7. ͳͥpushͰ͖ͳ͍ʁ         remote

    repo my repo ͢Ͱʹ৽͍͠ ίϛοτ͕ʂ
  8. มߋΛऔΓࠐΉ         remote

    repo my repo $ git pull origin master
  9.     remote repo my repo  

        มߋ͕औΓࠐ·Εͨʂ
  10.     remote repo my repo  

        $ git push origin master
  11.       remote repo my repo

          pushͰ͖ͨʂ
  12.          $

    git merge topic --ff merge
  13.          தͷਓ

    ʮtopicϒϥϯνͬͯmasterͷࠩ෼શ෦ ɹؚΜͰΔ͠ɺҰॹʹͪ͠Ό͑͹Α͘Ͷʁʯ merge
  14.          

    $ git merge topic --squash merge
  15. rebase         '

    ͜Ε͕Ϧϕʔεʂ
  16. rebase         

     $ git rebase master
  17. git

  18. git

  19. ίϯϑϦΫτΛमਖ਼ͯ͠ɺίϛοτ͠·͢ ίϯϑϦΫτ͸΋͏͍΍ͩ b <<<<<<< HEAD ccc ======= c >>>>>>> topic

    d b ccc d ίϯϑϦΫτղܾ࣌ʹɺίϯϑϦΫτղܾҎ্ͷ͜ͱΛͯ͠͸ ͍͚·ͤΜ Ͳͷ਌ʹ΋ݱΕͳ͍มߋΛ͍ͯ͠ΔϚʔδΛevil
  20. git

  21. git

  22. git