SlideShare a Scribd company logo
1 of 44
Download to read offline
Rozproszony system
   kontroli wersji

            GIT


 Piotr Macuk <piotr@macuk.pl>
O mnie


Programowanie       19 lat
Linux + vim         12 lat
Kontrola wersji      9 lat
Ruby (on Rails)      5 lat
Git                  2 lata
Agenda

Czym jest git
Instalacja i konfiguracja
Budowa
Narzędzia
Współpraca
Pytania
Historia
2002-2005 – BitKeeper
6 kwietnia 2005 – zmiana licencji
Linus daje sobie 2 tygodnie
18 kwietnia 2005 – git obsługuje swój kod
16 czerwca 2005 – git obsługuje kod jądra
Opiekun projektu: Junio Hamano
14 lutego 2007 – wydano git 1.5.0
Założenia


Nieliniowy rozwój kodu
Rozproszenie pracy
Szybkość i stabilność działania
Integralność repozytorium
Obsługa bardzo dużej ilości plików
Czym jest git?


Stupid content tracker
Ciekawy system plików
Filozofia UNIX-a – wiele prostych narzędzi


Git != svn++
Instalacja i konfiguracja
$ sudo apt­get install git­core

$ git config ­­global user.name  
"Piotr Macuk"
$ git config ­­global user.email  
piotr@macuk.pl

/etc/gitconfig
~/.gitconfig
.git/config
git help config
Nowy projekt

$ mkdir ­p pesel/src
$ touch pesel/README
$ touch pesel/src/pesel.rb

pesel
pesel/README
pesel/src
pesel/src/pesel.rb
Utworzenie repozytorium


$ git init

pesel
pesel/README
pesel/src
pesel/src/pesel.rb
pesel/.git
Ignore

$ cat .gitignore

*.log
*.pid
[0­9].txt

# production.log jest ok
!production.log
Status

$ git status

# On branch master
# Untracked files:
#       README
#       src/
nothing added to commit but 
untracked files present (use "git 
add" to track)
Nowe pliki

$ git add .
$ git status

# On branch master
# Changes to be committed:
#       new file:   README
#       new file:   src/pesel.rb
Commit
$ git commit ­m 'Init'

[master (root­commit) 7b355ec] Init
0 files changed, 0 insertions(+), 0 
deletions(­)
create mode 100644 README
create mode 100644 src/pesel.rb

$ git status

# On branch master
nothing to commit (working directory clean)
Perspektywa
      Katalog roboczy        Indeks        Repozytorium




            pesel       pesel/.git/index    pesel/.git



Add

Commit

Commit -a

Checkout
Baza obiektów


$ cd .git/objects && find

e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
29/206d2658aaf11920998fac41a9f5f7047418fb
4b/b2a6cec1e0c51741998cd243367706bbfb3b83
7b/355ecc8206060071ff60038fa034aab580dd59
Zmiana pliku



$ echo 'Pesel library.' > README
$ git add README
$ git commit ­m 'Doc'
Baza obiektów

$ cd .git/objects && find

e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
29/206d2658aaf11920998fac41a9f5f7047418fb
4b/b2a6cec1e0c51741998cd243367706bbfb3b83
7b/355ecc8206060071ff60038fa034aab580dd59
d3/db0ebf6844ddc3ef19920e753bdf66f332a565
50/947a5824bab56cf14775c6594745f5b4409f2f
6a/aa7ae7ded1c036bc433a49906733a81da6fc9e
SHA-1



                           Init       Doc

pesel                tree  4bb2a6c   6aaa7ae
pesel/README         blob  e69de29   50947a5
pesel/src            tree  29206d2   29206d2
pesel/src/pesel.rb   blob  e69de29   e69de29
Skierowany graf acykliczny
             Init           Doc

          commit           commit
          7b355ec          d3db0eb




           tree             tree
  pesel                              pesel
          4bb2a6c          6aaa7ae




    blob          tree      blob
   e69de29       29206d2   50947a5
    README          src    README
  src/pesel.rb
Typy obiektów
 blob        blob (size)0      tree            tree (size)0
e69de29                       4bb2a6c
                content                  100644 blob e69de29 README
                                         040000 tree 29206d2 src


commit                          tag
d3db0eb                       e795501

      Commit (size)0                   tag (size)0

tree 6aaa7ae                  object d3db0eb
parent 7b355ec                type commit
author Piotr Macuk            tag v0.0.1
   <piotr@macuk.pl>           tagger Piotr Macuk 
   1271161942 +0200              <piotr@macuk.pl> 
committer Piotr Macuk            Tue Apr 13 17:24:40 2010
   <piotr@macuk.pl> 
   1271161942 +0200           First tag.

Doc
Obiekty – założenia


Objekty są niezmienne
Obiekty są tylko dodawane
Ten sam sposób przechowywania

obj = zlib(sha1(header + content))
obj => .git/objects/
Gałęzie
         HEAD    $ git branch fix23
                 $ git checkout fix23
master   fix23



  F       D
                 $ git checkout ­b fix23

  E       C      $ git branch ­d fix23

  B



  A
Gałęzie


Nowy pomysł lub bug = nowa gałąź
Gałąź = wskaźnik na commit
Tworzenie gałęzi = zapis 40 bajtów do pliku
HEAD = gałąź w której jest katalog roboczy
Tagi


$ git tag v0.0.1
$ git tag ­a v1.0
$ git tag ­s v1.0signed
$ git tag ­l
Wskaźniki
                        $ cd .git/refs/ && find
 HEAD


master   fix23
                        tags/v0.0.1
                        heads/master
  F       D
                        heads/fix23

  E       C      tag: v0.0.1




  B



  A
Merge
$ git merge fix23                HEAD
$ git branch ­d fix23
                                master
      HEAD


                                  G
     master   fix23



       F       D                  F      D



       E       C                  E      C



       B                          B



       A                          A
Rebase + merge
                            HEAD                   HEAD


$ git checkout fix23                               master
                            fix23
$ git rebase master

                             D2                     D2
          HEAD


                             C2                     C2
 master   fix23   master



   F       D        F                                F



   E       C        E      $ git checkout master     E
                           $ git merge fix23
                           $ git branch ­d fix23
   B                B                                B



   A                A                                A
Historia – log
$ git log

commit d3db0ebf6844ddc3ef19920e753bdf66f332a565
Author: Piotr Macuk <piotr@macuk.pl>
Date:   Tue Apr 13 14:43:39 2010 +0200

    Doc

commit 7b355ecc8206060071ff60038fa034aab580dd59
Author: Piotr Macuk <piotr@macuk.pl>
Date:   Tue Apr 13 14:32:22 2010 +0200

    Init
Historia – log
$ git log
$ git log ­p
$ git log file1 file2 dir3
$ git log tag..branch
$ git log HEAD~10..
$ git log ­10
$ git log ­­author=fred
$ git log ­­grep="some text"
$ git log ­S"some code"
Historia – show
$ git show

commit d3db0ebf6844ddc3ef19920e753bdf66f332a565
Author: Piotr Macuk <piotr@macuk.pl>
Date:   Tue Apr 13 14:43:39 2010 +0200

    Dokumentacja

diff ­­git a/README b/README
index e69de29..50947a5 100644
­­­ a/README
+++ b/README
@@ ­0,0 +1 @@
+Pesel library.
Różnice
Katalog roboczy        Indeks        Repozytorium




     pesel        pesel/.git/index    pesel/.git


          git diff
                  git diff HEAD

                        git diff ­­cached
Undo



$ git commit ­­amend
$ git reset ­­soft
$ git reset ­­hard # UWAGA
Adresowanie

d3db0ebf6844ddc3ef19920e753bdf66f332a565
d3db0eb
HEAD, master, fix23, v0.0.1
master@{1 week ago}, fix23@{yesterday}
master~5, fix23^2, d3db0eb~2
'':/opis''
d3db0eb..7b355ec
Protokoły
git
ssh (+ gitshell)
http/https
File
rsync


http://github.com
Współpraca
Każde repozytorium jest samowystarczalne
Tworzymy sieć repozytoriów
Publiczne i prywatne
Główne repozytorium to tylko umowa


$ git clone url dir
$ git remote add janek url
$ git pull (lub git fetch)
$ git push
Lokalnie
        private                  private




         jan                     ola

jan$ git remote add ola file://home/ola/pesel
ola$ git remote add jan file://home/jan/pesel

$ git pull # bez push!

ola$ git branch ­a
* master
  remotes/jan/master
Współdzielenie
                         shared




   private     private            private   private




$ git clone ­­bare pesel pesel.git
$ scp ­r pesel.git server:~/
$ git remote add shared server:~/pesel.git
Open source
 public
 public        public      public
  main




private       private     private




Opiekun      Developer   Developer
Łaty


Współpraca na zasadzie wysyłania łat
$ git format­patch master~3
$ git apply *.patch
$ git add …
$ git commit
Wiele narzędzi
git grep             git blame
git cherry-pick      git bisect
git revert           git fsck
git archive          git gc
git stash            git prune
Narzędzia zewnętrzne

gitk (tcl/tk)
tig (console)
qgit (Qt)
TortoiseGit (Windows)
GitX (Mac OS X)
git svn (import, proxy)
Linki




http://git-scm.com
http://whygitisbetterthanx.com
Pytania?
Dziękuję za uwagę :)



 Piotr Macuk <piotr@macuk.pl>

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Git -- rozproszony system kontroli wersji