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/...
モデルから知るGit
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
モデルから知るGit
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
モデルから知るGit
•
    (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

More Related Content

KEY
定理3
PDF
デブサミ2011(17-B-3)講演資料「チケット駆動開発~タスクマネジメントからAgile開発へ」
PDF
RedmineのFAQとアンチパターン集
ODP
Why You Should Be Using Git
PDF
Git in action
PDF
Git Without Puns
PDF
Git 基础
定理3
デブサミ2011(17-B-3)講演資料「チケット駆動開発~タスクマネジメントからAgile開発へ」
RedmineのFAQとアンチパターン集
Why You Should Be Using Git
Git in action
Git Without Puns
Git 基础

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

KEY
Git Magic: Versioning Files like a Boss
PDF
Git cheat-sheets
PDF
GIT rozproszony system kontroli wersji
PDF
git - the stupid content tracker
KEY
Working with Git
PDF
SCMBC闇LT資料
PPTX
Git One Day Training Notes
PDF
Using git in eclipse by Chris Aniszczyk
KEY
The Git - (#1/2)
PDF
How to become a Git power user
PDF
[PUBLIC] Git – Concepts and Workflows.pdf
ODP
Introduction to Git (Greg Lonnon)
PPTX
Git session Dropsolid.com
PDF
Git Started With Git
KEY
Gitting the Most From Git
KEY
Git Tech Talk
PPTX
Introduction to git, a version control system
PDF
Git and Github
PDF
M.Mozūras - git
PPTX
Introduction To Git Workshop
Git Magic: Versioning Files like a Boss
Git cheat-sheets
GIT rozproszony system kontroli wersji
git - the stupid content tracker
Working with Git
SCMBC闇LT資料
Git One Day Training Notes
Using git in eclipse by Chris Aniszczyk
The Git - (#1/2)
How to become a Git power user
[PUBLIC] Git – Concepts and Workflows.pdf
Introduction to Git (Greg Lonnon)
Git session Dropsolid.com
Git Started With Git
Gitting the Most From Git
Git Tech Talk
Introduction to git, a version control system
Git and Github
M.Mozūras - git
Introduction To Git Workshop
Ad

More from Masahiro Honma (20)

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

モデルから知るGit