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

Git: A Motivating Introduction

Git: A Motivating Introduction

A conceptual and motivating introduction to Git (Presented in Oct 2013).

Jongwook Choi

October 25, 2013
Tweet

More Decks by Jongwook Choi

Other Decks in Programming

Transcript

  1. • GIT ਸ рۚೞѱ ࣗѐ೤פ׮. • ೐۽ં౟ীࢲ gitਸ ࢎਊ೧ࢲ ബҗ੸ੋ

    ੘সਸ ೡ ࣻ ੓঻ਵݶ જѷযਃ. • ஶࣆ, ࢎਊߨ, प੹ ੹ٜۚ ݽف… About this seminar.
  2. • GIT ਸ рۚೞѱ ࣗѐ೤פ׮. • ೐۽ં౟ীࢲ gitਸ ࢎਊ೧ࢲ ബҗ੸ੋ

    ੘সਸ ೡ ࣻ ੓঻ਵݶ જѷযਃ. • ஶࣆ, ࢎਊߨ, प੹ ੹ٜۚ ݽف…ח ೡ ࣻ হযਃƕƕ About this seminar.
  3. بҳܳ ରӔରӔ ߓ਋ӝীח दр੉ ݆੉ হযਃ -­‐-­‐ main porcelain command

    -­‐-­‐ add -­‐-­‐ add file contents to index am -­‐-­‐ apply patches from a mailbox archive -­‐-­‐ create archive of files from named tree bisect -­‐-­‐ find, by binary search, change that introduced a bug branch -­‐-­‐ list, create, or delete branches bundle -­‐-­‐ move objects and refs by archive checkout -­‐-­‐ checkout branch or paths to working tree cherry-­‐pick -­‐-­‐ apply changes introduced by some existing commits citool -­‐-­‐ graphical alternative to git commit clean -­‐-­‐ remove untracked files from working tree clone -­‐-­‐ clone repository into new directory commit -­‐-­‐ record changes to repository describe -­‐-­‐ show most recent tag that is reachable from a commit diff -­‐-­‐ show changes between commits, commit and working tree, etc. fetch -­‐-­‐ download objects and refs from another repository format-­‐patch -­‐-­‐ prepare patches for e-­‐mail submission gc -­‐-­‐ cleanup unnecessary files and optimize local repository grep -­‐-­‐ print lines matching a pattern gui -­‐-­‐ run portable graphical interface to git init -­‐-­‐ create empty git repository or re-­‐initialize an existing one log -­‐-­‐ show commit logs merge -­‐-­‐ join two or more development histories together mv -­‐-­‐ move or rename file, directory, or symlink notes -­‐-­‐ add or inspect object notes pull -­‐-­‐ fetch from and merge with another repository or local branch push -­‐-­‐ update remote refs along with associated objects rebase -­‐-­‐ fasforward-­‐port local commits to the updated upstream head reset -­‐-­‐ reset current HEAD to specified state revert -­‐-­‐ revert existing commits rm -­‐-­‐ remove files from the working tree and from the index shortlog -­‐-­‐ summarize git log output show -­‐-­‐ show various types of objects stash -­‐-­‐ stash away changes to dirty working directory status -­‐-­‐ show working-­‐tree status submodule -­‐-­‐ initialize, update, or inspect submodules tag -­‐-­‐ create, list, delete or verify tag object signed with GPG http://www.insightforums.com/ how-to-educate-your-customers-and-win-fans-for-life/
  4. Ӓېࢲ ౚషܻ঴ ١ਸ ࠁ׮ औѱ ࣗചೞप ࣻ ੓ب۾, ׼੢ ೐۽ં౟ীࢲ

    gitਸ ইए਍ ؀۽ ࢎਊೡ ࣻ ੓ب۾ ӒܻҊ gitਸ ॳݶ ب؀୓ ޖ঺੉ જ਷૑ ӝמ ࠁױ ೨ब ѐ֛ ਤ઱۽ рۚ൤ ૝যࠁب۾ ೞѷणפ׮.
  5. ഈসਸ ਤ೧ࢲח ਗѺ ੷੢ࣗ৬ ٮ ۽ زӝചೞח ੘স੉ ೙ਃ೧ਃ. ۽ஸ

    ੷੢ࣗ (local repository) ੘স ࢎࠄ (working copy) ਗѺ ੷੢ࣗ
  6. ੉ۧѱ ੷੢ࣗо ࠂઁغҊ ࠙࢑ػ ഋక۽ ઓ੤ೡ ࣻ ੓ӝ ٸޙী, DVCS

    (distributed VCS) ۄҊ ೧ਃ. http://nvie.com/posts/a-successful-git-branching-model/
  7. Commit ID : SHA-1 Hash 2670d94c6abf07e787efcd1867fafc86f62b6fac ഒز੉ হ׮ݶ ࠁా খ

    7~8Ӗ੗ܳ ٮࢲ ‘2670d94c’ ੉ۧѱ рױ൤ ࠗܰӝب ೧ਃ.
  8. ੋؙझ index (stage area) അ੤ ழ޿ೞҊ੗ ೞח ղਊ(߸ച)ٜਸ ੷੢ೞח Ҕ

    http://marklodato.github.io/visual-git-guide/index-en.html
  9. ௏٘ীࢲ য়ఋܳ рױ൤ ࣻ੿ೞח ழ޿ਸ ୶о೤द׮. ী٣ఠܳ ৌয ௏٘ܳ ࣻ੿೤פ׮.

    git status : যڃ ౵ੌ੉ ߸҃غ঻ח૑ ੿ࠁܳ ࠁৈસפ׮.
  10. ழ޿ೡ ղਊ(ژח ౵ੌ)ਸ stage ৔৉ী ୶о೤פ׮. (git add README.md) README.md

    ܳ ழ޿ೡ ળ࠺о غ঻णפ׮. other.txt ח ࣻ੿غ঻૑݅ ழ޿ೞ૑ ঋইਃ
  11. ب؀୓ ੋؙझ ѐ֛਷ ৵ ੓ਸөਃ? • ਗೞח ࠗ࠙݅ਸ ழ޿ೞৈ, ೞա੄

    ழ޿਷ ة݀੸ੋ ೞ ա੄ ߸ച݅ਸ ನೣ೧ঠ ೠ׮ח ߡ੹ ҙܻ੄ ਗ஗ਸ ૑ఆ ࣻ ੓ب۾ ب৬સפ׮. Issue #1: Implement an add function. http://www.mfranc.com/uncategorized/git-git-gui-staging-selected-lines/
  12. ب؀୓ ੋؙझ ѐ֛਷ ৵ ੓ਸөਃ? ௏٘ܳ ࣻ੿ೞ׮ࠁݶ э੉ ࣻ੿਷ ೮חؘ

    ࠗٙ੉ೞѱ ૑Ә ழ޿ೞӝח Ҍۆೠ ੌٜ੉ ࢤӡ ࣻ ੓যਃ. ݅ড SVN੉঻׮ݶ, - അ੤ ౵ੌਸ য٣ ׮ܲ Ҕী ੐द ߔস೧فҊ - commitೡ ࢚క۽ ౵ੌਸ ٜ݅যࢲ ழ޿ਸ ೠ ٍ - ׮द ߔস೧ك ౵ੌ۽ ࠂҳ೧ঠ ೡѢীਃ. ই ӈଳই…
  13. ӈଳইਃ. ੋؙझܳ ࢤۚೞח Ѫب оמ೤פ׮. • git commit -a ݺ۸ਸ

    ࢎਊ೤פ׮. • TortoiseGIT ١੄ ੌࠗ ௿ۄ੉঱౟ח ੋؙझ ѐ֛੉ হযࢲ, SVN୊ۢ ߄۽ ߸҃ػ ౵ੌਸ ழ޿ೞب۾ ٜ݅য ְযਃ.
  14. ࠳ے஖ branches ੷੢ࣗ ੉۱੄ ࢲ۽ ׮ܲ тې ژח ࠙ӝ. •

    ই૒ ৮ܐغ૑ ঋ਷ ӝמ੉ۄࢲ main ઴ӝী ߈৔ೞӝח ખ Ӓؘ۠ ழ޿җ ੉۱ ҙܻח ೧ ঠೡ ٸ • 1.3 ߡ੹ ѐߊ੉ ૓೯઺ੋؘ ц੗ӝ 1.2 ߡ੹ ীࢲ ߊѼػ ߡӒܳ ೥೗झ ೧ঠೡ ٸ • ف ݺ੄ ѐߊ੗о ࢲ۽ ׮ܲ ӝמਸ زदী ة݀੸ਵ۽ ѐߊೞҊ रਸ ٸ • …
  15. SVNীࢲח ٣۩షܻܳ ా૩۽ ࠂࢎೞৈ ֤ܻ੸ਵ۽ ࠳ ے஖ܳ ਍৔ೡ ࣻ ੓঻णפ׮.

    http://www.snipe.net/2009/03/getting-started-with-subversion-part-two/
  16. master ࠳ے஖ п ࠳ے஖ীࢲ ੘সೡ ٸ, ழ޿ਸ ୶оೞৈ ة݀ػ ੉۱ਸ

    ٜ݅ ࣻ ੓Ҋ ࠳ے஖ܳ ੗ਬ܂ѱ ৳׮щ׮ೡ ࣻ ੓যਃ. HEADח അ੤ working copy੄ baseо غח ழ޿੉ա ࠳ے஖ܳ ੄޷೤פ׮. (git checkout)
  17. ੉ٸח ف ࠳ے஖о оܻఃח ழ޿੄ ҕా ઑ࢚ਸ ଺ই ࢜۽਍ ழ޿(merge

    commit)ਸ ٟ݅פ׮. (non-fast-forward) master ࠳ے஖о оܻఃח ழ޿੉ খਵ۽ ੉ز೤פ׮. ݠ૑ ழ޿
  18. ൤झషܻܳ ࠌਸ ٸب ࠳ے஖о ঱ઁ ࡟যա৬ࢲ ঱ઁ য٣۽ ݠ૑غ঻ח૑о ݺഛೞѱ

    թणפ׮. (੉۱ ୶੸ਸ ਤ೧ blame ೧ࠁݶ पઁ۽ ߸҃ػ द੼ਸ ଺ਸ ࣻ ੓য ಞܻ೤פ׮) Merge branch ‘iss53’ into ‘master’
  19. п ѐߊ੗ח ઺ঔ ੷੢ࣗܳ cloneೠ ࢎࠄੋ ۽ஸ ੷੢ࣗ(local repository)ীࢲ ੘স೤פ׮.

    git clone GIT ࢲߡ ੷੢ࣗ (remote repository) git.mycompany.com/project-­‐a/test-­‐repo.git git clone git.mycompany.com/project-­‐a/test-­‐repo.git
  20. GIT ࢲߡ ੷੢ࣗ (remote repository) ੉ ٸ, ਗѺ ੷੢ࣗ(origin)ী ઓ੤ೞח

    ࠳ے஖ٜਸ ਗѺ ࠳ے஖(remote branch)ۄҊ ࠗܰҊ, ҳ߹ೞӝ ਤ೧ ۽ஸ ੷੢ࣗ੄ ࠳ے஖ܳ local branchۄҊ ࠗܵפ׮. ‘origin/master’ ١੄ ੉ܴਵ۽ ࠳ے஖ܳ աఋշפ׮.
  21. ੉ઁ ݻ о૑ ੘সਸ ૓೯೧ࢲ ழ޿ਸ ୶о೤פ׮. GIT ࢲߡ ੷੢ࣗ

    (remote repository) git.mycompany.com/project-­‐a/test-­‐repo.git
  22. যڃ ࠳ے஖ܳ ਗѺ ੷੢ࣗী ৢܻח Ѫਸ ಹद(push)ۄҊ ೤פ׮. GIT ࢲߡ

    ੷੢ࣗ (remote repository) git push origin master git.mycompany.com/project-­‐a/test-­‐repo.git
  23. ઺ঔ GIT ੷੢ࣗ ࢲߡ git fetch origin git.mycompany.com/project-­‐a/test-­‐repo.git ਗѺ ੷੢ࣗী

    ੓ח ழ޿ٜҗ ࠳ے஖ܳ оઉয়Ҋ, origin/master ١੄ remote branchо ੉ز(زӝച)ؾפ׮. ੉ ٸ ۽ஸ ࠳ے஖ח ߸ചೞ૑ ঋওणפ׮.
  24. ਗѺ ੷੢ࣗী pushೞ۰ݶ, ࠳ے஖ܳ খਵ۽ ׼ӝח fast-forwardо оמ೧ঠ ೤פ׮. ׮ܲ

    ࢎۈٜ੉ ੘সೠ ղਊਸ ݢ੷ ߉ইঠ ೤פ׮. merge ա rebase ੘স੉ ೙ਃ೤פ׮.
  25. master ࠳ے஖ী, 'origin/master' ࠳ے஖ܳ merge೤פ׮. (git merge origin/master) ੉ ٸ,

    ࠁా ইې৬ э਷ ழ޿ ݫद૑о ٜ݅য૘פ׮. Merge remote-tracking branch ‘origin/master’ into ‘master’
  26. ੉ۧѱ ೤஖Ҋ դ ٍ, push ೞݶ ؾפ׮. ੉ઁ origin/master ࠳ے஖੄

    ੑ੢ীࢲח fast-forwardо оמೞ޲۽ pushо ࢿҕ೤פ׮.
  27. ޥо ࠂ੟ೠ Ѫ эইਃ. Fetch & Mergeܳ ೣԋ ೧઱ח Pull

    ݺ۸ب ੓णפ׮. Ӓ۞ա fast-forwardо উ غח ҃਋ ੄بೞ૑ ঋ਷ merge commit੉ ࢤѹߡܾ ࣻ ੓য ઑब೧ঠ ೤פ׮.
  28. ӝמ੉ ա׊য૑ח ࠗ࠙੉ হযࢲ ౠ߹൤ ࠳ے஖о ೙ਃ হҊ ױࣽ൤ ௏٘ܳ

    ҕਬೞҊ र঻ਸ ࡺੋؘ, ॶؘহ੉ ࠂ੟ೠ ൤झషܻо ٜ݅য૕ ࣻ ੓যਃ. ൤झషܻܳ (SVN୊ۢ) ࢶഋਵ۽ ٜ݅ ࣻח হਸөਃ?
  29. rebase baseܳ ࢜۽੉ ೞ׮ ࢎप ׮ࣗ য۰਍ ѐ֛ੌ ࣻ ੓૑݅,

    git੄ ૓оܳ ߊൃೞӝ ਤ೧ࢲ ݒ਋ ਬਊೠ ӝמੑפ׮.
  30. rebase: master৬ origin/master੄ ੘স ղਊਸ ೤஖غ (ݠ૑ೞ૑ ঋҊ) fast-forwardо оמೞب۾

    ٜ݅Ҋ रযਃ. ੉Ѥ ۽ஸীࢲ ղо ݅ٚ ழ޿੉Ҋ ੉Ѥ ׮ܲ ࢎۈ੉ ݢ੷ ಹ दೠ ழ޿੉ীਃ
  31. experiment ࠳ے஖ীࢲ ੘সೞҊ ੓Ҋ, ழ޿ C3਷ C2ীࢲ ࡟যա৳ যਃ. experimentܳ

    master۽ rebaseೞৈ, C3 ழ޿ਸ C4 ٍী׮о লҊ रणפ׮. ( (experiment)$ git rebase master ) Rebaseۆ, ࠳ے஖੄ baseܳ ৤ӣਵ۽ॄ ழ޿ ൤झషܻܳ ׮द ॳח ੘সੑפ׮. ખ ؊ ੗ࣁ൤ ࢓ಝࠁইਃ.
  32. rebasing : experiment(C3)җ master(C4)੄ ҕాઑ࢚(C2)ਸ ଺ই, experiment ࠳ے஖ীࢲ C2 ੉റ੄

    ழ޿җ زੌೠ ߸҃ղ৉ਸ ыח ழ޿ਸ master(C4)੄ ٍী ٜ݅য ׳Ҋ experiment ࠳ے஖ܳ ੉ز೤פ׮. experiment ࠳ے஖ܳ master ࠳ے஖ ਤী rebase ೤פ׮.
  33. ৈӝࢲ C3' ਷ C3җח (߸҃ ղ৉җ ழ޿ ݫद૑ח э૑݅) ׮ܲ

    ࢜۽਍ ழ޿ੑפ׮.(SHA-1 ೧द IDо ׮ܰ׮)
  34. • ҕా੼ : ف ࠳ے஖о ೤୛૓ ࢚క(ழ޿)ܳ ٜ݅যસפ׮. • merge

    – ࢜۽਍ merge commit ਸ ٜ݅غ, ӝઓ੄ commit ё୓ٜਸ Ѥܻ٘૑ ঋणפ׮. • Rebase – ӝઓ੄ ࣻ੿ ղਊ੉ ׸ӟ commitਸ‘ࠂઁ’೧ࢲ ׮ܲ ࢜۽਍ commiਸ ٜ݅যસפ׮. – ٮۄࢲ Historyܳ ੌ૒ࢶਵ۽ ӭՔೞѱ ਬ૑ೡ ࣻ ੓যਃ. • ੗ࣁೠ Ѥ ۨಌ۠झ ଵҊ ߂ ׮਺ী… rebase, merge ޖ঺੉ ׮ܲоਃ?
  35. ޥ ࣗܽ૑ ੜ ݽܰदѷ׮ҳਃ? ই૒ pushೞ૑ ঋ਷ ழ޿੉ ੓חؘ, ੉޷

    ࢲߡী ৢۄৡ ߸҃ղ৉ਸ ೤୛ঠ ೠ׮ݶ git pull --rebase ܳ ࢎਊೞݶ જणפ׮.
  36. ࢲߡী ৢܻ૑ ঋҊب, ۽ஸ ੷੢ࣗীࢲ ݃਺؀۽ प೷ೞҊ పझ౟ ೞҊ ৈ۞о૑

    ੌਸ ೡ ࣻ ੓णפ׮. • ઺р/੐द ழ޿ਸ ݋؀۽ ೡ ࣻ ੓णפ׮. • ੘স੉ ৮ܐغݶ Ӓ ٸ ழ޿ਸ ೤஖Ҋ ׮ٞযࢲ ৢܾ ࣻ ੓णפ׮. • ٸ۽ח ৢܾ ೙ਃо হয૑ݶ Ӓր ߡ۰ب ؾפ׮.
  37. Pro Git : the official book http://git-scm.com/book/ko http://dogfeet.github.io/progit/progit.ko.pdf 여기에 수록된

    많은 git 관련 그림들은 pro-git (git-scm.com/book)에서 발췌했습니다.
  38. Other References • Git 간편 안내서 • http://rogerdudler.github.io/git-guide/index.html • (KO)

    http://rogerdudler.github.io/git-guide/index.ko.html • A Visual Git Guide • http://marklodato.github.io/visual-git-guide/index-en.html • (KO) http://marklodato.github.io/visual-git-guide/index-ko.html • SVN 사용자를 위한 Crash Course • http://git.or.cz/course/svn.html • Interactively learn Git Branching • http://pcottle.github.io/learnGitBranching/
  39. যڃ Git بҳ৬ ௿ۄ੉঱౟ܳ ࢎਊೞݶ ؼөਃ? • Git command-line shell

    • Editors (vim : fugitive.vim, Sublime text : SublimeGit) • IDE (Eclipse : EGit, IntelliJ IDEA : idea-git)
  40. ӝഥо ػ׮ݶ ׮਺ दрীח, • ࢎਊೞݶ ਬਊೠ ৈ۞о૑ ݺ۸য৬ ౲

    • Rebase۽ ੷੢ࣗ ੉۱ ઱ޖܰӝ • ഈস ઁ؀۽ ೞӝ : Workflow ߂ ࠳ے஖ ഝਊ ੹ۚ • ѐߊ੉ ইצ ׮ܲ ਊب۽ git ࢎਊೞӝ