Git basis and gitosis

Git basis and gitosis

Git の基本と gitosis :-)

3ccdb90bb443152e41221b4a2c5c65b7?s=128

Yasuhiro Asaka

April 09, 2011
Tweet

Transcript

  1. (JUͷجຊͱ HJUPTJT    *UBCBTIJ :BTVIJSP"TBLB

  2. ࣗݾ঺հ v"CPVUNF

  3. :BTVIJSP"TBLBXIPBNJ ‣vϓϩάϥϚ ‣v3VCZ 0CKFDUJWF$ .BD0494FSWFS ‣vখদࡊ͡Ό͕͍΋͑ΜͲ͏·Ί ‣v"SEVJOP ‣v"QQMF$FSUJGJFE)FMQ%FTL4QFDJBMJTU ‣v3VCZ"TTPDJBUJPO$FSUJGJFE3VCZ1SPHSBNNFS4JMWFS ‣v!HSBVXPFMGDIFO

    ‣vIUUQXXXHSBVXPFMGDIFOTMBCPSDPN
  4. ٞ୊ v"HFOEB

  5. vHJUPTJTΛ࢖͏ .BD0494FSWFSͰ "DDPVOUɺ3FNPUFSFQPTJUPSZ௥Ճ<%FNP> v(JUͷಛ௃ ಛ௃ɺجຊػೳ

  6. ಛ௃ɺجຊػೳ v(JUͷಛ௃

  7. ಛ௃ v෼ࢄܕ7$4ɺϩʔΧϧϦϙδτϦɾϒϥϯν vΠϯσοΫε vίϚϯυ͕ଟ͍ ศརෳࡶ vߴ଎ [MJCѹॖɺHJUϓϩτίϧɺϚʔδ  தԝू໿ܕ ෼ࢄܕ

    ӡ༻ํ๏͍ͩ͠ ରଟ
  8. master vϩʔΧϧϒϥϯν 4JOBUSBͰΈ͔͚ͨྫ POHJUIVC  ࣮ݧతͳ ଞͷਓʹӨڹ͠ͳ͍ ϒϥϯνΛ؆୯ʹ࡞ΕΔ ฏߦͨ͠࡞ۀ͕ਐΊΒΕΔ ෳ਺ίϛοτʹ·͕ͨΔ࿦ཧతͳมߋͷ୯Ґ΍ϦϦʔε

  9. vΠϯσοΫε ίϛοτͱϫʔΫπϦʔͷதؒʹҐஔ εςʔδϯάΤϦΞͱ΋ݺ͹ΕΔ εςʔδɾΞϯεςʔδͯ͠ɺίϛοτ͢ΔͨΊͷ಺༰Λ࡞Δ৔ॴ ΠϯσοΫεʹؚ·ΕΔҰ෦ ϋϯΫ ͚ͩΛίϛοτ΋Ͱ͖Δ $PNNJU *OEFY 8PSLJOHUSFF

    HJUBEE HJUDPNNJU
  10. Awesome Terminal - bash - ⌘ 1 $ mkdir test

    && cd test $ git init # => ॳظԽ Initialized empty Git repository in /path/to/test/.git/ $ echo test > test.txt $ git status # => ঢ়ଶͷ֬ೝ # On branch master # # Initial commit # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # test.txt nothing added to commit but untracked files present (use "git add" to track) $ git add -A # => εςʔδϯά $ git status # => ঢ়ଶͷ֬ೝ # On branch master # # Initial commit # # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # # new file: test.txt # $ git commit -m ‘created test.txt’ -m ‘initial commit !’ # => ίϛοτ [master (root-commit) a7d81b8] created test.txt 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 test.txt
  11. v෼ࢄܕͷϫʔΫϑϩʔ ΫϩʔϯϦϞʔτ͔Βྺ࢙͝ͱऔಘ ฤू εςʔδϯάΠϯσοΫεʹ௥Ճ ίϛοτϩʔΧϧϦϙδϦ΁ه࿥ ϓογϡϦϞʔτϦϙδτϦ΁ه࿥ ϑΣονϦϞʔτ΁ͷมߋͷऔಘ ϚʔδϫʔΩϯάπϦʔɺϒϥϯν΁Ϛʔδ ϦϙδτϦ࡞੒ϫʔΩϯάπϦʔͷมߋΛه࿥ ϓϧϑΣονͯ͠Ϛʔδ

    ϦϞʔτͷมߋऔΓࠐΈ ·ͨ͸
  12. جຊػೳ (JUʹݶΒͣ v࿦ཧతͳෳ਺ϑΝΠϧʹ·͕ͨΔมߋͷه࿥ vҎલͷίϛοτʹ໭Δ vมߋཤྺΛௐ΂Δ vͳͥͱ୭͕ͷه࿥ Awesome Terminal - bash

    - ⌘ 1 $ git config -l # => svn info ʹ૬౰ user.name=grauwoelfchen user.email=grauwoelfchen@gmail.com color.ui=auto # => Χϥʔදࣔ core.autocrlf=input # => ίϛοτ࣌ʹվߦίʔυΛLFʹἧ͑Δ core.excludesfile=/Users/grauwoelfchen/.gitexclude # => ڞ௨ͷແࢹઃఆϑΝΠϧ core.repositoryformatversion=0 core.filemode=true core.bare=false core.logallrefupdates=true core.ignorecase=true remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* remote.origin.url=git@github.com:foo.git # => ϦϞʔτϦϙδτϦ remote.moxssg.fetch=+refs/heads/*:refs/remotes/moxssg/* remote.moxssg.url=git@example.com:foo.git # => ϦϞʔτϦϙδτϦ
  13. Awesome Terminal - bash - ⌘ 1 $ git log

    -3 -p Gemfile # => ‘Gemfile’ ͱ͍͏ϑΝΠϧΛѻͬͨίϛοτͷ಺༰Λ3ͭ commit 9d3f4bc38f2d89d98567af017cf0327626e4effa Author: grauwoelfchen <grauwoelfchen@gmail.com> Date: Sun Apr 3 23:39:49 2011 +0900 specified version of maruku gem. diff --git a/Gemfile b/Gemfile index 99fa1f0..df7bac2 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gem 'bson_ext', '~> 1.2' gem 'data_mapper' gem 'mongoid_taggable' gem 'will_paginate', '~> 3.0.pre2' -gem 'maruku' +gem 'maruku', '~> 0.6.0' group :development do gem 'rspec', '2.5.0' commit 878ecc909708a46dfc1c85b23ed2c344b5343032 : vมߋཤྺΛௐ΂Δ vͳͥͱ୭͕ͷه࿥
  14. Awesome Terminal - bash - ⌘ 1 # ࢦఆͨ͠ϑΝΠϧʹؔ࿈͢Δίϛοτ਺Λௐ΂Δ $

    git rev-list --all Gemfile | wc -l 6 # ࢦఆͨ͠ϑΝΠϧͷ֤ߦͷมߋ͕Ͳͷίϛοτ͔Β͖͔ͨΛௐ΂Δ $ git blame Gemfile 497c0e86 (jobs 2011-03-09 11:57:22 +0900 1) source :gemcutter 497c0e86 (jobs 2011-03-09 11:57:22 +0900 2) 878ecc90 (jobs 2011-03-22 03:20:17 +0900 3) gem 'sinatra', '~> 1.2.0' 497c0e86 (jobs 2011-03-09 11:57:22 +0900 4) gem 'haml', '3.0.25' 497c0e86 (jobs 2011-03-09 11:57:22 +0900 5) gem 'mongoid', '2.0.0.rc.7' d2560ba3 (jobs 2011-03-21 11:59:52 +0900 6) gem 'bson_ext', '~> 1.2' # ಛఆͷϑΝΠϧʹ͓͚Δɺ͋ΔίϛοτͰͷมߋ಺༰Λௐ΂Δ $ git show HEAD~3 Gemfile commit 9d3f4bc38f2d89d98567af017cf0327626e4effa Author: grauwoelfchen <grauwoelfchen@gmail.com> Date: Sun Apr 3 23:39:49 2011 +0900 specified version of maruku gem. diff --git a/Gemfile b/Gemfile index 99fa1f0..df7bac2 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gem 'bson_ext', '~> 1.2' gem 'data_mapper' -gem 'maruku' +gem 'maruku', '~> 0.6.0'
  15. มߋͷݕ஌HJUCMBNF ྺ࢙ͷॻ͖׵͑HJUSFCBTF ϫʔΫπϦʔͷมߋऔΓফ͠HJUDIFDLPVU ΠϯσοΫεͷมߋऔΓফ͠HJUSFTFU ίϛοτͷมߋऔΓফ͠HJUSFTFUIBSE ίϛοτͷଧͪফ͠HJUSFWFSU มߋΛҰ࣌ԣʹஔ͍͓ͯ͘HJUTUBTI ϒϥϯνͷϚʔδHJUNFSHFCSBODI໊ ϩʔΧϧϒϥϯν࡞੒HJUDIFDLPVUCCSBODI໊ ϦϞʔτͷϒϥϯν࡟আHJUQVTI<SFNPUF>CSBODI໊

    vΑ͘࢖͏ίϚϯυ vΑ͘࢖͏ϑοΫ QSFDPNNJUϑοΫ ίϛοτͷ಺༰νΣοΫͳͲ DPNNJUNTHϑοΫ ϝοηʔδͷ౷ҰͳͲ QPTUVQEBUFϑοΫ QVTIΛड͚ͯσϓϩΠͤͨ͞Γ
  16. vଞͷ෼ࢄ7$4ͱൺֱϦΫΤετ͍͖ͨͩ·͕ͨ͠ ίϚϯυɺπʔϧͷҧ͍ͦ͋͜Εɺ ϫʔΫϑϩʔ͸͋Μ·ΓҧΘͳ͍ɻͱࢥ͏ svn͔Βͷ੾Γସ͑ઌʹbzrΛݕ౼͢ΔͳͲʢ࠷ऴతʹ͸hgʹͳͬͨ‥ʣ IUUQUPHFUUFSDPNMJ ෼ࢄόʔδϣϯ؅ཧGit/Mercurial/Bazaarపఈൺֱ IUUQXXXBUNBSLJUDPKQGKBWBSFOTBJEFWUPPM EFWUPPM@IUNM

  17. None
  18. େ੾ͳͷ͸πʔϧͷ༏ྼͰ͸ͳ͘ Ͳ͏࢖͏͔ ͍͍Θ͚

  19. .BD0494FSWFS΁Πϯετʔϧ vHJUPTJTΛ࢖͏

  20. ໨త χʔζ vTTIͰηΩϡΞʹ௨৴͍ͨ͠ vެ։ݤͷొ࿥͕൥ࡶ vγΣϧΞΫηε͸ͤͨ͘͞ͳ͍ vϦϞʔτϦϙδτϦ࡞੒Λ؆୯ʹ͍ͨ͠ vϦϙδτϦ୯ҐͰΞΫηεݖΛઃఆ͍ͨ͠

  21. ໨త χʔζ vTTIͰηΩϡΞʹ௨৴͍ͨ͠ vެ։ݤͷొ࿥͕൥ࡶ vγΣϧΞΫηε͸ͤͨ͘͞ͳ͍ vϦϞʔτϦϙδτϦ࡞੒Λ؆୯ʹ͍ͨ͠ vϦϙδτϦ୯ҐͰΞΫηεݖΛઃఆ͍ͨ͠ ˠHJUPTJTBENJOHJUͰ؅ཧ

  22. vIPNFHJU͕6TFSTHJUʹͳΔ v6TFSTHJUCBTISDͰHJU ίϚϯυ ΁ύε௨͢ v4FSWFS"ENJOͰHJUϢʔβʹ44)ΛڐՄ 0494FSWFSͷ৔߹ Awesome Terminal - bash

    - ⌘ 1 # gitosis Πϯετʔϧ $ python --version Python 2.5.1 $ git clone git://eagain.net/gitosis.git $ cd gitosis $ sudo python setup.py install ... # Ϣʔβ࡞੒ # dscl . -create /Users/git # dscl . -create /Users/git UserShell /bin/bash # dscl . -create /Users/git RealName "git" # dscl . -create /Users/git NFSHomeDirectory /Users/git # dscl . -create /Users/git UniqueID xxx # dscl . -create /Users/git PrimaryGroupID xxx # createhomedir -b -u git
  23. Awesome Terminal - bash - ⌘ 1 # ΋͢͠Ͱʹ؅ཧ͍ͯ͠ΔϦϙδτϦ͕ͨͪͲ͔͜ʹ͋Ε͹ $

    ln -s /srv/repos/git /Users/git/repositories $ sudo chown -R git /Users/git/repositories # ϩʔΧϧͰ (؅ཧऀͷެ։伴Λసૹ͓ͯ͘͠) $ scp ~/.ssh/id_rsa.pub admin@example.com:/tmp/git # => ϩʔΧϧϚγϯ ... # gitosis ॳظԽ $ sudo -H -u git gitosis-init < /path/to/id_rsa.pub Initialized empty Git repository in /srv/repos/git/gitosis-admin.git/ Reinitialized existing Git repository in /srv/repos/git/gitosis-admin.git/ ... # post-update ϑοΫͷΞΫηεݖमਖ਼ $ sudo chmod 755 /srv/repos/git/gitosis-admin.git/hooks/post-updat # git ίϚϯυ΁ͷ PATH Λ௨͢ $ touch ~/.bashrc $ echo PATH=/usr/local/bin:\$PATH > .bashrc # => brew install git ͍ͯͨ࣌͠ $ echo export PATH >> .bashrc # Πϯετʔϧ׬ྃ !! # ಈ࡞֬ೝɺϢʔβ௥ՃɺϦϙδτϦ௥ՃͷσϞ $ sudo demo
  24. Awesome Terminal - bash - ⌘ 1 $ exit logout

    [My LT completed] # ͋Γ͕ͱ͏͍͟͝·ͨ͠