1 / 52

GIT

GIT. Distributed Version Control System (we like it and you should too ). Turinys. Asmeninė patirtis Kilmė Distributed / centralized Vidinė struktūra Metadata Terminologija Darbas lokaliai: nauda, komandos: init, checkout, branch, merge, reset, stash, gui, gitk. Turinys.

alanna
Télécharger la présentation

GIT

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. GIT Distributed Version Control System (we like it and you should too)

  2. Turinys • Asmeninė patirtis • Kilmė • Distributed / centralized • Vidinė struktūra • Metadata • Terminologija • Darbas lokaliai: nauda, komandos: init, checkout, branch, merge, reset, stash, gui, gitk

  3. Turinys • Darbas remote: clone, remote, fetch, push • Serverio pusė: gitosis • Online servisai • CVS / SVN integracija • Git on Windows • Summa summarum

  4. Truputis asmeniškumų • Vartojau CVS. • Pabėgau į SVN. • SVN valdė! • Kol neprireikė sumergint. • Bet buvo galima gyventi. • Ilgai spyriojaus prieš GIT. • Perėjau. • Nesigailiu.

  5. Kilmė • Sukurta valdyti Linux branduoliui, po to, kai BitKeeper tapo mokamas. • Linus manė, jog centralizuotos sistemos “čiulpia”. Citata: “if you’re using SVN you’re stupid”. Ar kažkas panašaus  • CVS – puikus pavyzdys ko nedaryti. • Daryti sistemą paskirstytą, greitą ir atsparią duomenų išgadinimui.

  6. Ką reiškia paskirstyta (distributed)? • Pilna repozitorija laikoma visuose PC. • Nėra centrinio serverio, visi lygūs. • Jeigu kažkas dingo “centriniame” serveryje – ne bėda, visi, kas dirba su projektu, turi pilną repozitorijos kopiją.

  7. Centralizuota VCS Kiekvienas klientas turi vienos versijos duomenis. Serveris turi visas versijas.

  8. Centralizuota VCS – kas blogai? O kas, jeigu....

  9. Centralizuota VCS – kas blogai? O kas, jeigu....

  10. Centralizuota VCS – kas blogai? O kas, jeigu....     

  11. Centralizuota VCS – kas blogai? Repozitorijos info, kaip branchai, tagai ir senesnės revizijos – prarasta.

  12. Decentralizuota VCS

  13. Decentralizuota VCS

  14. Decentralizuota VCS    

  15. Decentralizuota VCS    

  16. Decentralizuota VCS    

  17. Decentralizuota VCS GAME OVER    

  18. Be visa ko... • GIT yra greitas! Commit’as trunka kokius 0.01 sekundės. • Duomenų nusiuntimas į kitą serverį trunka 0.2 sekundės + kokia jūsų interneto sparta. • Fun fact: GIT visa repozitorija užima mažiau vietos, negu vienas SVN checkoutas  • Let’s try it out.

  19. Vidinė struktūra • Git has two data structures, a mutable index that caches information about the working directory and the next revision to be committed, and an immutable, append-only object database containing four types of objects: • A blob object is the content of a file. Blob objects have no names, timestamps, or other metadata. • A tree object is the equivalent of a directory: it contains a list of filenames, each with some type bits and the name of a blob or tree object that is that file, symbolic link, or directory's contents. This object describes a snapshot of the source tree. • A commit object links tree objects together into a history. It contains the name of a tree object (of the top-level source directory), a timestamp, a log message, and the names of zero or more parent commit objects. • A tag object is a container that contains reference to another object and can hold additional meta-data related to another object. Most commonly it is used to store a digital signature of a commit object corresponding to a particular release of the data being tracked by Git. • Jeigu kam įdomu detaliau: http://excess.org/article/2008/07/ogre-git-tutorial/ • Realiai dirbant – nereikia žinoti.

  20. GIT metadata • find -name .svn -exec rm -rfv \{\} \; • Matyta?  • Git, skirtingai nuo CVS ar SVN, savo metadata laiko vienoje direktorijoje: PROJECT_ROOT/.git • Yra keli papildomi failai: .gitignore, .gitmodules

  21. Truputį teorijos/terminologijos • Commit • Branch • Tracking branch • Tag

  22. Commit

  23. Branch/Tracking branch/Tag Pagrindinė šaka: master

  24. Dirbti su GIT nereikia interneto! • Lokalios repozitorijos sukūrimas: git init • Su lokalia repo galima daryti viską, ką ir centralizuotoje su nutolusia: commit, checkout, branch, merge ir t.t. • Kam to reikia?

  25. Situacija I • Deployinama per FTP. Dirbama ant kažkokios feature, išlindo kritinis bugas versijoje, kuri padeployinta. • Be VCS: • Kopijuojam stable kodą pas save, modifikuojam, uploadinam. • Kaip sumerginti?  Tikrinti failų skirtumus ranktėmis?

  26. Situacija I • Su VCS: • git checkout stable • Darom pakeitimus • git commit • Uploadinam • git checkout feature • Baigiame feature. • git checkout stable • git merge feature

  27. Situacija II • Dirbama su kolega, repozitorija prieinama per shared diską, daromi keli featurai vienu metu. Padarei feature A, gali pradėti daryti feature B, tačiau iki deploymento reikia, kad kolega padarytu feature A (tarkim sudizainintu). • Be VCS: • Jei pradėsi B – kaip sumerginti? • Jei nepradėsi – ką veiksi?

  28. Git dažniausiai lokaliai naudojamos komandos • git init – inicializuoją naują repozitoriją • git gui • gitk --all • git checkout [-b] – persijungimas [ir sukūrimas] į šaką • git branch – įvairios šakų operacijos • git merge • git reset --hard • git stash

  29. git merge

  30. git merge D:\Work\testrepo>git merge a b c Trying simple merge with d40f0de23c714dd2007ccf0a11753ffe2516c20b Trying simple merge with eca4a1aac1ae8b71fd65743e72aac9b2f225093f Simple merge did not work, trying automatic merge. Auto-merging test.txt ERROR: Merge conflict in test.txt fatal: merge program failed Automated merge did not work. Should not be doing an Octopus. Merge with strategy octopus failed. 

  31. Duomenų failo turinys Additions of A. Initial data. <<<<<<< .merge_file_a00956Additions of A. =======Additions of B. Additions of B. >>>>>>> .merge_file_a02220 What a wonderfull mess!

  32. Kokia situacija repozitorijoje?

  33. git reset --hard • Numeta HEAD ir failų sistemą į tam tikrą commit. D:\Work\testrepo>git reset --hard master HEAD is now at 38f45f0 Initial commit.

  34. Pabandom kitaip D:\Work\testrepo>git merge a Updating 38f45f0..d40f0de Fast forward test.txt | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) D:\Work\testrepo>git merge b Auto-merging test.txt CONFLICT (content): Merge conflict in test.txt Automatic merge failed; fix conflicts and then commit the result.

  35. Turinys Additions of A. Initial data. <<<<<<< HEAD:test.txtAdditions of A. =======Additions of B. Additions of B. >>>>>>> b:test.txt Pataisom rankutėmis 

  36. Situacija REPO

  37. Situacija REPO

  38. + merge c

  39. git stash • Ne taip dažnai naudojama, bet kartais naudinga.

  40. Darbas su remote • Nors visi lygūs, vienas dažniausiai būna lygesnis už kitus  - pristatome jums serverį. • Priėjimas per git protokolą, HTTP arba ssh. • git clone - nusiklonuoja repozitoriją • git remote - nutolusių serverių sąrašas • git fetch • git push remote_name branches

  41. git remote \individualus>git remote -v origin git@www:iptproj.git

  42. git fetch individualus>git fetch From git@www:iptproj + 6baa748...16e25c4 Jho -> origin/Jho (forced update)

  43. git fetch

  44. git push origin arturaz \individualus>git push origin arturaz Counting objects: 3, done. Compressing objects: 100% (2/2), done. Writing objects: 100% (2/2), 238 bytes, done. Total 2 (delta 1), reused 0 (delta 0) To git@www:iptproj.git a8c5947..67e03bc arturaz -> arturaz

  45. Serverio pusė • gitosis - GIT hook’ų krūva, kuri tvarko priėjimą per SSH. • Autentifikacija - SSH raktais. • Priėjimas prie projektų - gitosis.conf • Viskas per vieną SSH vartotoją, niekas neturi shell’o, saugu!

  46. Online servisai • github.com - OSS projektams - nemokamai, kitiems - mokėjimo planai. • repo.or.cz • google: git hosting

  47. Integracija su CVS/SVN • git cvs ir git svn • Leidžia klonuoti, sinchronizuoti repozitorijas. • Gali naudoti git net jeigu visa komanda naudoja SVN! • Tiesa, ne visai idealu 

  48. Git on Windows • Git - *NIX sistemų vaikas ir ten jam smagiausia. • msysgit - http://code.google.com/p/msysgit/ portas į Windows. • Autentifikacijai - PuTTY suite: putty, plink, pageant. • Veikia, naudojuosi, patenkintas.

More Related