SlideShare una empresa de Scribd logo
1 de 90
Descargar para leer sin conexión
Git
2011   3   9
       (id:hiratara)
•         (id:hiratara)

•
•     Perl

      Python Java Haskell

•   Git
• Git
•
•
•
hoge.git/
hoge/.git/         bare            config
 config                             refs
 refs                              ...
 ...



             dir    hoge/                     dir
                     .gitignore
                     hoge.txt
             dir     ...
Git
Git

•
• Linus
•
Git
.git/
• .git/config
   git config



• .git/refs/...
Author: hiratara
Date: 2/25 13:43:42

typo



index.html
images/flower.gif
css/index.css
js/index.js
•
    (               )

•              2

•       (   root)

•
•

•
    =
        index.html
    =
                     flower.gif   index.js
git   svn

SVN




Git
        A   B     C   D
git   svn
                  git merge --squash


SVN




Git
git      svn
• git
 • git   ID

     →

 •
     →
git
•

•
    →

•             ID
remotes/origin/master
tags/0.9973            heads/topic



                          heads/master
=refs/heads

•                  ref       .git/refs

    • .git/refs/tags/
    • .git/refs/heads/
    • .git/refs/remotes/
ref
• .git/
• .git/refs/
• .git/refs/tags/
• .git/refs/heads/
• .git/refs/remotes/
ref
•          2

    heads/hiratara/master
    remotes/hiratara/master
• hiratara/master
• remotes/hiratara/master
topic   master
git commit(1)
topic

        1



            master
git commit(2)
    topic

1           2



            master
topic

1           2



            master
git merge
    topic

1           2



                master
git commit(3)
    topic

1           2



                    master
                3
topic
    topic

1           2



                        master
                    3
git commit(4)
    topic

1   2       4



                    master
                3
ID
•
          ID
    →ID

•              ID

    →               ID
    →ID
ID   SHA1
     •
	    	    	 
                                	 
                                	 
                                	 
                                	 

     •                     ID
•         ID

    →ID

    →

• Git
topic

B           C



            master
       A
git rebase

B       C               B C

        master        topic
    A       B’   C’
topic

B           C



            master
       A
git cherry-pick B
     topic

 B           C



                      master
        A        B'
git cherry-pick C
     topic

 B           C



                           master
        A        B'   C'
master
A   B   C
rebase -i HEAD~3
                  master
   A'   B'   C'




   A    B    C




             A B C
reflog
          •
          • git reflog show master                           C
             master
master
A'   B'   C'




A    B    C
git reset C

A'   B'   C'




               master
A    B    C
master
A   B   C
git revert A


                    master
A   B   C      -A
topic   master
commit
topic




        master
git merge master
   topic




     master
3
.git
                       topic
                       master

       A   B   C   D




       D                        D
•
    •
•       staged   cached
.git
                       topic
                       master

       A   B   C   D




       D                        D’
git add
.git
                           topic
                           master

        A   B    C     D



                 add
       D’                           D’
.git
                        topic
                        master

        A   B   C   D




       D’                        D’’
git add
.git
                            topic
                            master

        A    B    C     D



                  add
       D’’                           D’’
git commit
.git
                            topic
                                     master

         A      B   C   D     D’’

       commit


        D’’                         D’’
• D’
    →

•
3
.git
                              topic
                              master

         A      B   C     D
                                 commit -a
       commit                    commit filename

                    add
        D’                             D’’
(1)
.git
                            topic
                   master
       A   B   C       D




       D                            D
git checkout master
.git
                            topic
                   master
       A   B   C       D




       C                            C
(2)
.git
                             topic
                    master
        A   B   C       D




       D'                            D''
git checkout master .
.git
                            topic
                   master
       A   B   C       D




       C                            C
git checkout .
.git
                             topic
                    master
        A   B   C       D




       D'                            D'
(1)
.git
                             topic
                    master
        A   B   C       D




       C'                            C''
git reset --soft topic
.git
                              topic
                              master

        A       B   C     D




       C'                              C''
git reset topic
.git
                         topic
                         master

       A   B    C    D




       D                          C''
git reset --hard topic
.git
                        topic
                        master

       A   B   C    D




       D                         D
•
    (origin/master                          )

•                    git fetch   git push
git@github.com:him/hoge.git

 A      B     C      D master


~/git-repos/hoge

 A      B     C     X master
git remote add
github => git@github.com:him/hoge.git

 A      B     C      D master


                         git remote add github git@...
~/git-repos/hoge

 A      B     C      X master
git fetch
github => git@github.com:him/hoge.git

 A      B     C      D master

                            git fetch github
~/git-repos/hoge            (   git remote update)

                    D github/master

 A      B     C     X master
refspec
•
• push, fetch
  (fetch                               )
github
heads/from      git fetch github from:to
heads/to        ※       heads

heads/to        git push github from:to
heads/from
fetch       refspec

• git remote add

•
merge rebase
github => git@github.com:him/hoge.git

 A      B     C      D master


~/git-repos/hoge             git rebase github/master

                    D github/master

 A      B     C     X      X` master
git push
github => git@github.com:him/hoge.git

 A      B     C      D       X` master


~/git-repos/hoge                    git push github

                    D github/master

 A      B     C     X      X` master
push              refspec
• refspec
  →"                        push"

• push.default
  nothing, matching, tracking, current
• remote.<name>.push
  (F/W           fetch                   )
fetch         pull       push(1)
github => git@github.com:him/hoge.git
heads/master
heads/another
                         git fetch github
~/git-repos/hoge         remote.<name>.fetch
remotes/github/master
remotes/github/another
heads/master
heads/local-branch
heads/another
fetch         pull         push(2)
github => git@github.com:him/hoge.git
heads/master
heads/another            branch.<name>.remote

~/git-repos/hoge                git pull = fetch + merge
remotes/github/master
remotes/github/another        branch.<name>.merge
heads/master
heads/local-branch
heads/another
fetch         pull         push(3)
github => git@github.com:him/hoge.git
heads/master
heads/another
                         git push github
~/git-repos/hoge         push.default=matching
remotes/github/master
remotes/github/another
heads/master
heads/local-branch
heads/another
github
origin/topic1   master

origin/master
                         topic1   master
hanako taro clone
origin/topic1   master

origin/master
                         topic1   master




origin/topic1

origin/master
hanako topic2
origin/topic1     master

origin/master
                           topic1   master




origin/topic1   topic2

origin/master
hanako taro fork
origin/topic1     master

origin/master
                           topic1   master




origin/topic1   topic2

origin/master
                           topic1   master
git remote -f add
origin/topic1      master

 origin/master
                             topic1   master




hanako/topic1
 origin/topic1   topic2
hanako/master
 origin/master
                             topic1   master
git push hanako topic2
origin/topic1      master

 origin/master
                                            topic1   master




hanako/topic1
 origin/topic1   topic2     hanako/topic2
                                                         topic2
hanako/master
 origin/master
                                            topic1   master
tarou pull-req
origin/topic1      master

 origin/master
                                            topic1   master




                                                          pull request
hanako/topic1
 origin/topic1   topic2     hanako/topic2
                                                         topic2
hanako/master
 origin/master
                                            topic1   master
taro remote add
hanako/topic1    master   hanako/topic2
 origin/topic1
hanako/master
 origin/master
                                          topic1   master




hanako/topic1
 origin/topic1   topic2   hanako/topic2
                                                       topic2
hanako/master
 origin/master
                                          topic1   master
merge hanako/topic2
hanako/topic1    master   hanako/topic2
 origin/topic1
hanako/master
 origin/master
                                          topic1   master




hanako/topic1
 origin/topic1   topic2   hanako/topic2
                                                       topic2
hanako/master
 origin/master
                                          topic1   master
git push origin master
hanako/topic1    master   hanako/topic2
 origin/topic1
hanako/master             origin/master               master
 origin/master
                                          topic1




hanako/topic1
 origin/topic1   topic2   hanako/topic2
                                                       topic2
hanako/master
 origin/master
                                          topic1   master
github
• git         svn


    →

•       git

Más contenido relacionado

Similar a モデルから知るGit

Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a BossGit Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Bosstmacwilliam
 
Git cheat-sheets
Git cheat-sheetsGit cheat-sheets
Git cheat-sheetsozone777
 
GIT rozproszony system kontroli wersji
GIT rozproszony system kontroli wersjiGIT rozproszony system kontroli wersji
GIT rozproszony system kontroli wersji3camp
 
git - the stupid content tracker
git - the stupid content trackergit - the stupid content tracker
git - the stupid content trackerhenrikau
 
SCMBC闇LT資料
SCMBC闇LT資料SCMBC闇LT資料
SCMBC闇LT資料bleis tift
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notesglen_a_smith
 
Using git in eclipse by Chris Aniszczyk
Using git in eclipse by Chris AniszczykUsing git in eclipse by Chris Aniszczyk
Using git in eclipse by Chris AniszczykEclipseDayParis
 
How to become a Git power user
How to become a Git power userHow to become a Git power user
How to become a Git power userDeveo
 
[PUBLIC] Git – Concepts and Workflows.pdf
[PUBLIC] Git – Concepts and Workflows.pdf[PUBLIC] Git – Concepts and Workflows.pdf
[PUBLIC] Git – Concepts and Workflows.pdfChimaEzeamama1
 
Git session Dropsolid.com
Git session Dropsolid.comGit session Dropsolid.com
Git session Dropsolid.comdropsolid
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With GitNick Quaranto
 
Gitting the Most From Git
Gitting the Most From GitGitting the Most From Git
Gitting the Most From GitChris Miller
 
Introduction to git, a version control system
Introduction to git, a version control systemIntroduction to git, a version control system
Introduction to git, a version control systemKumaresh Chandra Baruri
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshopthemystic_ca
 

Similar a モデルから知るGit (20)

Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a BossGit Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
 
Git cheat-sheets
Git cheat-sheetsGit cheat-sheets
Git cheat-sheets
 
GIT rozproszony system kontroli wersji
GIT rozproszony system kontroli wersjiGIT rozproszony system kontroli wersji
GIT rozproszony system kontroli wersji
 
git - the stupid content tracker
git - the stupid content trackergit - the stupid content tracker
git - the stupid content tracker
 
Working with Git
Working with GitWorking with Git
Working with Git
 
SCMBC闇LT資料
SCMBC闇LT資料SCMBC闇LT資料
SCMBC闇LT資料
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Using git in eclipse by Chris Aniszczyk
Using git in eclipse by Chris AniszczykUsing git in eclipse by Chris Aniszczyk
Using git in eclipse by Chris Aniszczyk
 
The Git - (#1/2)
The Git - (#1/2)The Git - (#1/2)
The Git - (#1/2)
 
How to become a Git power user
How to become a Git power userHow to become a Git power user
How to become a Git power user
 
[PUBLIC] Git – Concepts and Workflows.pdf
[PUBLIC] Git – Concepts and Workflows.pdf[PUBLIC] Git – Concepts and Workflows.pdf
[PUBLIC] Git – Concepts and Workflows.pdf
 
Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)
 
Git session Dropsolid.com
Git session Dropsolid.comGit session Dropsolid.com
Git session Dropsolid.com
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
 
Gitting the Most From Git
Gitting the Most From GitGitting the Most From Git
Gitting the Most From Git
 
Git Tech Talk
Git  Tech TalkGit  Tech Talk
Git Tech Talk
 
Introduction to git, a version control system
Introduction to git, a version control systemIntroduction to git, a version control system
Introduction to git, a version control system
 
Git and Github
Git and GithubGit and Github
Git and Github
 
M.Mozūras - git
M.Mozūras - gitM.Mozūras - git
M.Mozūras - git
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
 

Más de Masahiro Honma

レンズ (ぶつかり稽古の没プレゼン)
レンズ (ぶつかり稽古の没プレゼン)レンズ (ぶつかり稽古の没プレゼン)
レンズ (ぶつかり稽古の没プレゼン)Masahiro Honma
 
すべてが@__kanになる
すべてが@__kanになるすべてが@__kanになる
すべてが@__kanになるMasahiro Honma
 
Types and perl language
Types and perl languageTypes and perl language
Types and perl languageMasahiro Honma
 
カレーとHokkaidopm
カレーとHokkaidopmカレーとHokkaidopm
カレーとHokkaidopmMasahiro Honma
 
モナモナ言うモナド入門.tar.gz
モナモナ言うモナド入門.tar.gzモナモナ言うモナド入門.tar.gz
モナモナ言うモナド入門.tar.gzMasahiro Honma
 
モナモナ言うモナド入門
モナモナ言うモナド入門モナモナ言うモナド入門
モナモナ言うモナド入門Masahiro Honma
 
循環参照のはなし
循環参照のはなし循環参照のはなし
循環参照のはなしMasahiro Honma
 
Hachioji.pm in Machida の LT
Hachioji.pm in Machida の LTHachioji.pm in Machida の LT
Hachioji.pm in Machida の LTMasahiro Honma
 
ウヰスキーとPSGI
ウヰスキーとPSGIウヰスキーとPSGI
ウヰスキーとPSGIMasahiro Honma
 
YAPCレポートの舞台裏
YAPCレポートの舞台裏YAPCレポートの舞台裏
YAPCレポートの舞台裏Masahiro Honma
 
Stateモナドの解説 後編
Stateモナドの解説 後編Stateモナドの解説 後編
Stateモナドの解説 後編Masahiro Honma
 

Más de Masahiro Honma (20)

レンズ (ぶつかり稽古の没プレゼン)
レンズ (ぶつかり稽古の没プレゼン)レンズ (ぶつかり稽古の没プレゼン)
レンズ (ぶつかり稽古の没プレゼン)
 
すべてが@__kanになる
すべてが@__kanになるすべてが@__kanになる
すべてが@__kanになる
 
Types and perl language
Types and perl languageTypes and perl language
Types and perl language
 
Currying in perl
Currying in perlCurrying in perl
Currying in perl
 
カレーとHokkaidopm
カレーとHokkaidopmカレーとHokkaidopm
カレーとHokkaidopm
 
モナモナ言うモナド入門.tar.gz
モナモナ言うモナド入門.tar.gzモナモナ言うモナド入門.tar.gz
モナモナ言うモナド入門.tar.gz
 
モナモナ言うモナド入門
モナモナ言うモナド入門モナモナ言うモナド入門
モナモナ言うモナド入門
 
Perl saved a lady.
Perl saved a lady.Perl saved a lady.
Perl saved a lady.
 
Levenshtein Automata
Levenshtein AutomataLevenshtein Automata
Levenshtein Automata
 
20120526 hachioji.pm
20120526 hachioji.pm20120526 hachioji.pm
20120526 hachioji.pm
 
循環参照のはなし
循環参照のはなし循環参照のはなし
循環参照のはなし
 
Arrows in perl
Arrows in perlArrows in perl
Arrows in perl
 
Hachioji.pm in Machida の LT
Hachioji.pm in Machida の LTHachioji.pm in Machida の LT
Hachioji.pm in Machida の LT
 
Monads in perl
Monads in perlMonads in perl
Monads in perl
 
ウヰスキーとPSGI
ウヰスキーとPSGIウヰスキーとPSGI
ウヰスキーとPSGI
 
YAPCレポートの舞台裏
YAPCレポートの舞台裏YAPCレポートの舞台裏
YAPCレポートの舞台裏
 
Git入門
Git入門Git入門
Git入門
 
AnyEvent and Plack
AnyEvent and PlackAnyEvent and Plack
AnyEvent and Plack
 
Math::Category
Math::CategoryMath::Category
Math::Category
 
Stateモナドの解説 後編
Stateモナドの解説 後編Stateモナドの解説 後編
Stateモナドの解説 後編
 

モデルから知るGit