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

Git - 運用編

Git - 運用編

Naomichi Yamakita

May 14, 2012
Tweet

Transcript

  1. ֓ཁ  %5ʹ͓͚Δ(JUͷجຊ։ൃαΠΫϧ  ։ൃऀ͸PSJHJO͔ΒϦϙδτϦͷΫϩʔϯΛ࡞੒  ֤ࣗͷ։ൃ؀ڥͰ։ൃΛਐΊɺมߋ಺༰Λςεταʔόʹ൓ө͢Δ  ςετ؀ڥͰಈ࡞֬ೝ 

    εςʔδϯά؀ڥʹσϓϩΠ  ϓϩμΫγϣϯ؀ڥʹσϓϩΠ  ϦϦʔε׬ྃ  ؾܰʹϒϥϯνΛ੾ΕΔͨΊɺϧʔϧΛܾΊͳ͍ͱࠞཚͷݩͱͳΔ
  2. ӡ༻ϙϦγʔ  ։ൃϦϙδτϦͰ͸ɺ࢓༷ॻ΍֤छυΩϡϝϯτʢٞࣄ࿥ɺݟੵॻɺσʔ λϑΝΠϧ౳ʣΛ؅ཧ͠ͳ͍  3FENJOF (PPHMF"QQTͰҰݩ؅ཧ  ϑΝΠϧ໊͸ӳޠʹ౷Ұ͢Δ 

    ೔ຊޠϑΝΠϧ໊͸ɺ.BD΍-JOVY؀ڥԼͰಈ࡞͕ෆ҆ఆͳͨΊ  σϕϩούʔϙʔλϧجຊݪଇϑΝΠϧͱσΟϨΫτϦ 
 IUUQQSPKFDUTWDTFSWJDFOFUHVJEFMJOF CBTF@HVJEFMJOFIUNM fi MF@SVMF  (JUͰ͸ݪଇతʹιʔεϑΝΠϧʢٴͼ෇ਵ͢Δ"1*ʣͷΈΛ؅ཧ͢Δ
  3. ӡ༻ϙϦγʔ  ίϛοτϝοηʔδʹมߋ಺༰ͷ֓ཁΛه͢  ίϛοτ࣌ʹ։ൃؔ܎ऀ΁ϩάϝʔϧ͕ࣗಈૹ৴͞ΕΔ  ϦϙδτϦͷ࡞੒ํ๏ʢ%5ࣾһͷΈʣ $ cd /usr/local/git/repositories/

    $ su git $ git init --bare --shared=true {repository_name}.git Initialized empty shared Git repository in /usr/local/git/ repositories/{repository_name}.git/ $ cd ../gitosis-admin/ $ vi gitosis.conf $ git commit -m “add {repository_name” -a $ git push ϦϙδτϦͷύʔϛογϣϯΛઃఆ ڞ༗ϦϙδτϦͷઃఆ
  4.  ϒϥϯνͷछྨ  ϒϥϯνͷछྨ  ϝΠϯϒϥϯν  NBTUFS  EFWFMPQ

     αϙʔτϒϥϯν  GFBUVSF  SFMFBTF  IPU fi Y
  5. ϝΠϯϒϥϯνͷछྨ  NBTUFS  ৗʹϦϦʔεՄೳঢ়ଶ  ։ൃͰ͸࢖༻͠ͳ͍ɺλά෇͚ઐ༻ͷϒϥϯν  EFWFMPQ 

    ։ൃ༻్ͷϒϥϯν  ։ൃ׬ྃޙ͸NBTUFSϒϥϯν΁Ϛʔδ  ͜ͷࡍʹNBTUFSϒϥϯν্Ͱλά෇͚Λߦ͏
  6. GFBUVSFϒϥϯνͷछྨ  GVBUVSF  ࣮ݧஈ֊ͷػೳΛ։ൃ͢Δࡍʹ࢖༻͢Δ  ϒϥϯνಛੑ  ෼ذݩEFWFMPQ 

    ϚʔδઌEFWFMPQ  ৔߹ʹΑͬͯ͸Ϛʔδ͞Εͣഁغ͞ΕΔ͜ͱ΋͋Γ͏Δ  ϒϥϯν໊ͷنଇGVBUVSF\UJDLFU@JE^  \UJDLFU@JE^ରԠ͢Δ3FENJOFͷνέοτ*%
  7. GFBUVSFϒϥϯνͷछྨ  SFMFBTF  ৽͍͠ػೳΛϦϦʔε͢Δ௚લʹ࢖༻͢Δ  ϚΠφʔόάϑΟοΫε΍࠷ऴௐ੔͸SFMFBTFϒϥϯνͰߦ͏  ϒϥϯνಛੑ 

    ෼ذݩEFWFMPQ  ϚʔδઌEFWFMPQͱNBTUFS  NBTUFSʹϚʔδ͢Δࡍ͸λάΛ෇͚Δ  ϒϥϯν໊ͷنଇSFMFBTF\ZZZZNNEE^
  8. GFBUVSFϒϥϯνͷछྨ  IPU fi Y  ϦϦʔεࡁΈͷ੡඼ʹ͓͚ΔΫϦςΟΧϧͳόάΛमਖ਼͢Δ  EFWFMPQϒϥϯν͸ଞͷػೳΛ։ൃதͰෆ҆ఆͳՄೳੑ͕͋Δ 

    ϒϥϯνಛੑ  ෼ذݩNBTUFS  ϚʔδઌEFWFMPQͱNBTUFS  NBTUFSʹϚʔδ͢Δࡍ͸λάΛ෇͚Δ  SFMFBTF͕ଘࡏ͢Δ৔߹͸EFWFMPQͷ୅ΘΓʹSFMFBTFʹϚʔδ  ϒϥϯν໊ͷنଇIPU fi Y\ZZZZNNEE^@\UJDLFU@JE^
  9. HJU fl PX  l"TVDDFTTGVM(JUCSBODIJOHNPEFMzͷϞσϧΛӡ༻͠΍͘͢͢Δϓϥά Πϯ  IUUQTHJUIVCDPNOWJFHJU fl PX

     HJU fl PXͷηοτΞοϓʢ8JOEPXT-JOVY.BDʣ  IUUQXXXPSFJMMZDPKQDPNNVOJUZCMPHCSBODINPEFM XJUIHJU fl PXIUNM
  10. HJU fl PXͷ࣮ߦ  ϦϙδτϦͱϒϥϯνΛ࡞੒͢Δ $ git flow init Initialized

    empty Git repository in /Users/naomichi/Desktop/ testrep/.git/ No branches exist yet. Base branches must be created now. Branch name for production releases: [master] Branch name for "next release" development: [develop] How to name your supporting branch prefixes? Feature branches? [feature/] Release branches? [release/] Hotfix branches? [hotfix/] Support branches? [support/] Version tag prefix? [] $ git branch -a * develop master NBTUFSϒϥϯνɺGFBUVSFϒϥϯνΛ໋໊ GFBUVSFϒϥϯν͸දࣔ͞Εͳ͍ʢޙड़ʣ
  11. GFBUVSFϒϥϯνͷ࡞੒  ৽ػೳͷ։ൃΛ։࢝͢Δ $ echo 'hello' > greeting $ git

    add . $ git commit -m "first commit" $ git flow feature start 100 Switched to a new branch 'feature/100' Summary of actions: - A new branch 'feature/100' was created, based on 'develop' - You are now on branch 'feature/100' Now, start committing on your feature. When done, use: git flow feature finish 100 $ git branch develop * feature/100 master 3FENJOFͷ։ൃΛ։࢝ EFWFMPQϒϥϯνΛݩʹGFBUVSFϒϥϯν͕࡞੒͞Εͨ ϒϥϯν͕௥Ճ͞ΕΔ
  12. GFBUVSFϒϥϯνͷ࡞੒  GFBUVSFͷ։ൃΛऴΘΒͤͯEFWFMPQʹ໭ΔʢϚʔδ͢Δʣ $ echo 'good night' > greeting $

    git commit -m "second commit" -a $ git flow feature finish 100 Switched to branch 'develop' Updating 01f0874..58f1c0d Fast-forward greeting | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) Deleted branch feature/100 (was 58f1c0d). Summary of actions: - The feature branch 'feature/100' was merged into 'develop' - Feature branch 'feature/100' has been removed - You are now on branch 'develop' $ cat greeting good night $ git branch * develop master GFBUVSFϒϥϯνͷऴΘΓΛએݴ EFWFMPQϒϥϯνʹϚʔδ͞ΕɺGFBUVSFϒϥϯν͕࡟আ͞ΕΔ EFWFMPQϒϥϯνʹϚʔδ͞Εͨ͜ͱ͕֬ೝͰ͖Δ GFBUVSFϒϥϯν͸࡟আࡁΈ
  13. SFMFBTFϒϥϯνͷ࡞੒  ϦϦʔεόʔδϣϯΛ࡞੒ $ git flow release start 20120401 Switched

    to a new branch 'release/20120401' Summary of actions: - A new branch 'release/20120401' was created, based on 'develop' - You are now on branch 'release/20120401' Follow-up actions: - Bump the version number now! - Start committing last-minute fixes in preparing your release - When done, run: git flow release finish '20120401' $ git branch develop master * release/20120401 SFMFBTFϒϥϯνΛ։࢝ EFWFMPQϒϥϯνΛݩʹSFMFBTFϒϥϯν͕࡞੒͞Εͨ SFMFBTFϒϥϯν͕ΞΫςΟϒʹͳΔ
  14. SFMFBTFϒϥϯνͷ࡞੒  ϓϩάϥϜͷඍௐ੔ΛՃ͑ͨޙʹϦϦʔεΛߦ͏ $ echo 'good mornink' good mornink $

    git commit -m "first commit" $ git flow release finish 1.0 Switched to branch 'master' Merge made by recursive. greeting | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 greeting create mode 100644 hello Deleted branch release/1.0 (was 58f1c0d). Summary of actions: - Latest objects have been fetched from 'origin' - Release branch has been merged into 'master' - The release was tagged '1.0' - Release branch has been back-merged into 'develop' - Release branch 'release/1.0' has been deleted [naomichi: test]$ git tag 20120401 SFMFBTFϒϥϯνΛऴྃ͠ɺNBTUFSEFWFMPQϒϥϯνʹϚʔδ͢Δ ϚʔδͱNBTUFSϒϥϯν΁ͷλά෇͚͕ߦΘΕͨ
  15. IPU fi Yϒϥϯνͷ࡞੒  ϦϦʔεࡁΈͷϓϩάϥϜʹର͠मਖ਼ΛՃ͑Δ $ git flow hotfix start

    20120401_200 Switched to a new branch 'hotfix/20120401_200' Summary of actions: - A new branch 'hotfix/20120401_200' was created, based on 'master' - You are now on branch 'hotfix/20120401_200' Follow-up actions: - Bump the version number now! - Start committing your hot fixes - When done, run: git flow hotfix finish '20120401_200' $ git branch develop * hotfix/20120401_200 master 3FENJOFͷϗοτϑΟοΫεΛ։࢝ NBTUFSϒϥϯνΛݩʹIPU fi YϒϥϯνΛ࡞੒ IPU fi Yϒϥϯν͕௥Ճ͞ΕΔ
  16. IPU fi Yϒϥϯνͷ࡞੒  ϗοτϑΟοΫεͷద༻ $ echo 'good night' >

    greeting $ git commit -m "fixed spell" -a # On branch hotfix/20120401_200 nothing to commit (working directory clean) $ git flow hotfix finish 20120401_200 Switched to branch 'develop' Already up-to-date! Merge made by recursive. Deleted branch hotfix/20120401_200 (was 8aeddfd). Summary of actions: - Latest objects have been fetched from 'origin' - Hotfix branch has been merged into 'master' - The hotfix was tagged '20120401_200' - Hotfix branch has been back-merged into 'develop' - Hotfix branch 'hotfix/20120401_200' has been deleted εϖϧϛεΛमਖ਼ͯ͠ίϛοτ ϗοτϑΟοΫεΛऴΘΒͤΔ ϗοτϑΟοΫεΛNBTUFSEFWFMPQϒϥϯνʹ൓ө