SlideShare uma empresa Scribd logo
1 de 42
Baixar para ler offline
Git in Action
Agenda
●   Introduction

●   Action
●   Q&A
Introduction
Distributed Version Control

    Remote              Repository     Repository   Repository
(public or privat)
                                                          push



                                                          pull


                     Workspace        Workspace      Workspace


    Local       Repository           Repository     Repository

                      Alice            Bob           Charlie
Git repository
repository = object database




         .git/objects
Git repository
id(object) = SHA1(object content)


     4afd                 57aa
            34da 45f5             90ff
                          aabc
                   3daa              9873
                          78dd
            12df                     8810
                   675b    aacc
            456c                  ddaa


.git/objects/45/6c...
Git repository
content is stored in blob objects => File


       4afd                 57aa
              34da 45f5             90ff
                            aabc
                     3daa              9873
                            78dd
              12df                     8810
                     675b    aacc
              456c                  ddaa
Git repository
structure is stored in tree objects => Directory


          4afd                 57aa
                 34da 45f5             90ff
                               aabc
                        3daa              9873
                               78dd
                 12df                     8810
                        675b    aacc
                 456c                  ddaa
Git repository
History is stored in commit objects =>
     Authenticated hierarchical snapshots


       4afd             57aa 90ff
              34da 45f5      78dd

       9873             aabc 8810
                3daa
                             ddaa
              12df
                        aacc 456c
                             675b
Git repository
Git repository
references are stored as tag objects =>
          (Signed)symbolic link


       4afd             57aa 90ff
              34da 45f5      78dd

       9873             aabc 8810
                3daa
                             ddaa
              12df
                        aacc 456c
                             675b
Git repository
       repository entry point =>
                 symbolic link
              branches
                         master

       4afd             57aa 90ff
              34da 45f5      78dd
tags                     aabc 8810
       9873     3daa
                              ddaa
              12df
                         aacc 456c
                              675b
Action
The most important
                commands
●   add           ●   fetch   ●   rebase

●   bisec         ●   grep    ●   remote

●   branch        ●   init    ●   reset

●   checkout      ●   log     ●   rm

●   clone         ●   merge   ●   show

●   commit        ●   mv      ●   stash

●   config        ●   pull    ●   status

●   diff          ●   push    ●   tag
Configuration in
         $HOME/.gitconfig
git config --global user.name "Some name"

git config --global user.email some@email

git config --global color.branch auto

git config --global color.diff auto

git config --global color.interactive auto

git config --global color.status auto

git config --global merge.tool meld

git config --global core.editor vim
Initializing a repository
●   Create a new repository

    git init



●   Clone an existing repository

    git clone <url>



●   Possible URLs:

    ●   local directory, ssh://, git://, rsync://,
        ftp:// etc.
Show the status
●   Simply call git status

●   This will show the lifecycle of the files



➔   A file which is indexed and modified afterwards, must be
    added explicitly to the index again!
The Index

Working Copy                  Index              Repository

          git add,
                                      git commit
           rm, mv

●   Buffer between working copy and repository

●   Describes what's commited next

●   Shortcut: git commit -a
Commit
●   Changes stored in the index are written into the
    repository and get a new SHA1 checksum

●   The HEAD-reference points to the new commit

●   The last commit can be changed and re-committed
    using the --amend parameter, e.G. typos in the
    comment, missed changes to be commited etc.


       git commit --amend
Show differences
●   Between workspace and index
      git diff

●   Between index and the last commit
      git diff --staged

●   Between the workspace and the last commit
      git diff HEAD

●   Between two commits
      git diff $commit $commit

●   Between current branch and another one
      git diff branch_name
Object references
●   SHA1: d37f32a8058b2c4b5d1b1c55c4cab41611899cb3

●   Short SHA1:        d37f32a

●   Tags:              v1.5.1

●   Local branch:      master

●   Remote branch:     origin/master

●   Checkout:          HEAD

●   Last Fetch:        LAST_FETCH

●   Previous Head:     ORIG_HEAD
Object references
●   Parents: Name^, Name^^^, Name~10, Name^2, …

●   What was yesterday?    Name@{yesterday}

●   What was on ...?       Name@{1 June}

●   What was … days before?Name@{3}

●   What happened since...? --since=“2 weeks ago“

●   What was until ...?       --until=“1 week ago“

●   Who has...?               --committer=pattern

●   What was between...?   name1..name2
Show me the commit
●   Prints the diffs in a commit

●   Shows diffs as well as statistics

     ●   git show

     ●   git show --stat

●   Can be used with all object references
Reset
●   git reset modifies different elements:

    ●   Variant 1: --hard
        The HEAD, the index and all local modifications in
        the workspace will be erased!

    ●   Variant 2: --soft
        The HEAD will be overwritten. Previous commits will
        change to „changes to be committed“

    ●   Variante 3: --mixed (default)
        The HEAD and the index are overwritten

●   The HEAD is just a reference to a specific commit
Logs
●   Shows the commit logs

    ●   git log

    ●   git log -10

●   Can be used with all object references

    ●   git log -3 master@{15 July}

    ●   git log --author=Max Mustermann

    ●   git log --grep=pattern
Search in files
●   git provides a grep integration

●   MUCH faster than standard grep


    git grep -e pattern -- some/file


    git grep -e pattern branch -- some/file
Tags
●   Tags are named references to commits

●   There are annotated and lightweight tags

●   Creation of a tag

     ●   Lightweight:      git tag <name>

     ●   Annotated:           git tag -a <name> -m „message“

●   Show all tags:      git tag
Create and change
                     branches
●   Branches are references to commits

●   The default-branch is called master

●   Create: git branch name [commit]

●   Change: git checkout name

●   Create and change: git checkout -b name

●   The HEAD will be adapted accordingly
Delete branches
●   Branches can be deleted every time

●   To delete a merged branch
      git branch -d branch_name

●   To delete a non-merged branch
      git branch -D branch_name
Show all branches
●   Local ones
       git branch

●   Remote ones
       git branch -r

●   All branches
       git branch -a

●   All non-merged branches
       git branch --no-merged
Conflicts and merging
●   Merge as many branches as you want at the same time
        git merge branch_a branch_b

●   Merged branches can also be deleted

●   Conflict markers indicates auto-merge problems

    ●   Show with git status or git mergetool

    ●   Use editor or mergetool to fix the conflict

    ●   Stash the resolved conflict on the index

    ●   Do a commit
Cherry-pick
●   Sometimes you only want to merge specific commits into
    another branch

●   Git allows this cherry picking


       git cherry-pick <commit>
Rebase
●   Alternative to git merge

●   Simple rebase pushes the branch onto the HEAD


git merge master   test        git rebase master    test

                    f                                e'

                    e                                d'    e

                    d                                      d

     master   c                            master    c

              b                                      b

              a                                      a
Interactive rebase
●   git rebase -i master

●   Handles multiple commits:
                                       f   t(e+f)   master
     ●   delete
                                       e
     ●   ignore
                                       d   s(d)
     ●   edit
                                       c
     ●   squash together
                                       b     b
●   You can squash multiple commits
                                       a
    into one to have a clean history
Remote Branches
●   Clone creates a new local branch within a namespace:
        remotes/origin/<branch name>

●   Default-name for remote server is origin

    ●   Can be changed using git remote

●   Checkout a remote branch using
        git checkout -b <remote_name>/<branch>

●   Remote branches are Tracking Branches
Adding remotes
●   Unlimited number of remotes

●   Modifications with git remote

●   Typing git remote will list all remotes



➔   Team members can add other team members remotes
    for easy code exchange
Pull the changes
●   Tracking-branches know the SHA1 from the remote since
    the last pull

●   Changes are fetched using
         git fetch remote:branch

     ➔   Note, these changes are not merged yet!

●   Shortcut: Do a pull


         git pull remote:branch


               = git fetch + git merge
Provide your changes
●   Store the commits on a central repository server

●   Not all local branches must be pushed → private stuff
    keeps private!


       git push remote:branch



➔   NEVER change the history of distributed changes using
    rebase!
Stashing
●   Common problem:

    ●   Current work must be pushed asside but the changes
        shouldn't be commited yet

    ●   Changes in the workspace/index must be transfered
        in another branch

●   Solution: The index and changed files are cached and
    the workspace and index is resetted
        git stash save „description“
        git stash apply
        git stash pop       # apply and drop
Stashing episode II
●   Advantage: Stashing indexes the files and write them
    into the reflog

●   Even if these changes are never commited, you can get
    them back
       git stash list
       git log stash@{10}
       git show stash@{26}
       git checkout -b old_work stash@{32}

●   Use stashes simply like branches

➔   The reflog exists independent from the commits
Blame
●   Problem: You don't know who implemented the code
    snippet

●   Solution: git blame -- file shows a list of changes for
    a file and when and who modified it
Q&A

Mais conteúdo relacionado

Mais procurados

Présentation de git
Présentation de gitPrésentation de git
Présentation de gitJulien Blin
 
Git basics to advance with diagrams
Git basics to advance with diagramsGit basics to advance with diagrams
Git basics to advance with diagramsDilum Navanjana
 
Git and Github slides.pdf
Git and Github slides.pdfGit and Github slides.pdf
Git and Github slides.pdfTilton2
 
Презентация Git-flow (на русском)
Презентация Git-flow (на русском)Презентация Git-flow (на русском)
Презентация Git-flow (на русском)Sergey Chudakov
 
Gitlab flow solo
Gitlab flow soloGitlab flow solo
Gitlab flow soloviniciusban
 
Advanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeAdvanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeMd Swawibe Ul Alam
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash CourseNilay Binjola
 
Git Series. Episode 3. Git Flow and Github-Flow
Git Series. Episode 3. Git Flow and Github-FlowGit Series. Episode 3. Git Flow and Github-Flow
Git Series. Episode 3. Git Flow and Github-FlowMikhail Melnik
 
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overviewGit and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overviewRueful Robin
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and GithubHouari ZEGAI
 

Mais procurados (20)

Présentation de git
Présentation de gitPrésentation de git
Présentation de git
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Git basics to advance with diagrams
Git basics to advance with diagramsGit basics to advance with diagrams
Git basics to advance with diagrams
 
Basic Git Intro
Basic Git IntroBasic Git Intro
Basic Git Intro
 
GitHub Basics - Derek Bable
GitHub Basics - Derek BableGitHub Basics - Derek Bable
GitHub Basics - Derek Bable
 
Git and Github slides.pdf
Git and Github slides.pdfGit and Github slides.pdf
Git and Github slides.pdf
 
Презентация Git-flow (на русском)
Презентация Git-flow (на русском)Презентация Git-flow (на русском)
Презентация Git-flow (на русском)
 
Gitlab flow solo
Gitlab flow soloGitlab flow solo
Gitlab flow solo
 
Git best practices workshop
Git best practices workshopGit best practices workshop
Git best practices workshop
 
Advanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeAdvanced Git Presentation By Swawibe
Advanced Git Presentation By Swawibe
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
 
Versioning avec Git
Versioning avec GitVersioning avec Git
Versioning avec Git
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Git Series. Episode 3. Git Flow and Github-Flow
Git Series. Episode 3. Git Flow and Github-FlowGit Series. Episode 3. Git Flow and Github-Flow
Git Series. Episode 3. Git Flow and Github-Flow
 
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overviewGit and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
Git and Github Session
Git and Github SessionGit and Github Session
Git and Github Session
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
 
GitLab.pptx
GitLab.pptxGitLab.pptx
GitLab.pptx
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 

Destaque

git01 เอกสารประกอบวิดีโอสอนใช้งาน git สำหรับมือใหม่
git01 เอกสารประกอบวิดีโอสอนใช้งาน git สำหรับมือใหม่git01 เอกสารประกอบวิดีโอสอนใช้งาน git สำหรับมือใหม่
git01 เอกสารประกอบวิดีโอสอนใช้งาน git สำหรับมือใหม่Thapwaris Chinsirirathkul
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use ItDaniel Kummer
 
Git 101 Presentation
Git 101 PresentationGit 101 Presentation
Git 101 PresentationScott Chacon
 
Getting Git Right
Getting Git RightGetting Git Right
Getting Git RightSven Peters
 
Ruby On Rails Introduction
Ruby On Rails IntroductionRuby On Rails Introduction
Ruby On Rails IntroductionThomas Fuchs
 

Destaque (6)

Mastering GIT
Mastering GITMastering GIT
Mastering GIT
 
git01 เอกสารประกอบวิดีโอสอนใช้งาน git สำหรับมือใหม่
git01 เอกสารประกอบวิดีโอสอนใช้งาน git สำหรับมือใหม่git01 เอกสารประกอบวิดีโอสอนใช้งาน git สำหรับมือใหม่
git01 เอกสารประกอบวิดีโอสอนใช้งาน git สำหรับมือใหม่
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
 
Git 101 Presentation
Git 101 PresentationGit 101 Presentation
Git 101 Presentation
 
Getting Git Right
Getting Git RightGetting Git Right
Getting Git Right
 
Ruby On Rails Introduction
Ruby On Rails IntroductionRuby On Rails Introduction
Ruby On Rails Introduction
 

Semelhante a Git in action

Honestly Git Playground 20190221
Honestly Git Playground 20190221Honestly Git Playground 20190221
Honestly Git Playground 20190221Shinho Kang
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptuallyseungzzang Kim
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practiceMajid Hosseini
 
New Views on your History with git replace
New Views on your History with git replaceNew Views on your History with git replace
New Views on your History with git replaceChristian Couder
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmdsrinathcox
 
Introduction of Git
Introduction of GitIntroduction of Git
Introduction of GitWayne Chen
 
Getting some Git
Getting some GitGetting some Git
Getting some GitBADR
 
Git-ing out of your git messes
Git-ing out of  your git messesGit-ing out of  your git messes
Git-ing out of your git messesKatie Sylor-Miller
 
Gitting It Under (Version) Control
Gitting It Under (Version) ControlGitting It Under (Version) Control
Gitting It Under (Version) Controlmobiledevnj
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | WorkshopAnuchit Chalothorn
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git TutorialSage Sharp
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notesglen_a_smith
 
Git a stupid change tracker and persistent map.
Git a stupid change tracker and persistent map.Git a stupid change tracker and persistent map.
Git a stupid change tracker and persistent map.Pitambar Jha
 

Semelhante a Git in action (20)

Honestly Git Playground 20190221
Honestly Git Playground 20190221Honestly Git Playground 20190221
Honestly Git Playground 20190221
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
 
Git basics 2
Git basics 2Git basics 2
Git basics 2
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
 
Git in a nutshell
Git in a nutshellGit in a nutshell
Git in a nutshell
 
New Views on your History with git replace
New Views on your History with git replaceNew Views on your History with git replace
New Views on your History with git replace
 
Git
GitGit
Git
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmd
 
Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)
 
Introduction of Git
Introduction of GitIntroduction of Git
Introduction of Git
 
Getting some Git
Getting some GitGetting some Git
Getting some Git
 
Git-ing out of your git messes
Git-ing out of  your git messesGit-ing out of  your git messes
Git-ing out of your git messes
 
Gitting It Under (Version) Control
Gitting It Under (Version) ControlGitting It Under (Version) Control
Gitting It Under (Version) Control
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | Workshop
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Git basic
Git basicGit basic
Git basic
 
Git a stupid change tracker and persistent map.
Git a stupid change tracker and persistent map.Git a stupid change tracker and persistent map.
Git a stupid change tracker and persistent map.
 
Git Tech Talk
Git  Tech TalkGit  Tech Talk
Git Tech Talk
 

Git in action

  • 2. Agenda ● Introduction ● Action ● Q&A
  • 4. Distributed Version Control Remote Repository Repository Repository (public or privat) push pull Workspace Workspace Workspace Local Repository Repository Repository Alice Bob Charlie
  • 5. Git repository repository = object database .git/objects
  • 6. Git repository id(object) = SHA1(object content) 4afd 57aa 34da 45f5 90ff aabc 3daa 9873 78dd 12df 8810 675b aacc 456c ddaa .git/objects/45/6c...
  • 7. Git repository content is stored in blob objects => File 4afd 57aa 34da 45f5 90ff aabc 3daa 9873 78dd 12df 8810 675b aacc 456c ddaa
  • 8. Git repository structure is stored in tree objects => Directory 4afd 57aa 34da 45f5 90ff aabc 3daa 9873 78dd 12df 8810 675b aacc 456c ddaa
  • 9. Git repository History is stored in commit objects => Authenticated hierarchical snapshots 4afd 57aa 90ff 34da 45f5 78dd 9873 aabc 8810 3daa ddaa 12df aacc 456c 675b
  • 11. Git repository references are stored as tag objects => (Signed)symbolic link 4afd 57aa 90ff 34da 45f5 78dd 9873 aabc 8810 3daa ddaa 12df aacc 456c 675b
  • 12. Git repository repository entry point => symbolic link branches master 4afd 57aa 90ff 34da 45f5 78dd tags aabc 8810 9873 3daa ddaa 12df aacc 456c 675b
  • 14. The most important commands ● add ● fetch ● rebase ● bisec ● grep ● remote ● branch ● init ● reset ● checkout ● log ● rm ● clone ● merge ● show ● commit ● mv ● stash ● config ● pull ● status ● diff ● push ● tag
  • 15. Configuration in $HOME/.gitconfig git config --global user.name "Some name" git config --global user.email some@email git config --global color.branch auto git config --global color.diff auto git config --global color.interactive auto git config --global color.status auto git config --global merge.tool meld git config --global core.editor vim
  • 16. Initializing a repository ● Create a new repository git init ● Clone an existing repository git clone <url> ● Possible URLs: ● local directory, ssh://, git://, rsync://, ftp:// etc.
  • 17. Show the status ● Simply call git status ● This will show the lifecycle of the files ➔ A file which is indexed and modified afterwards, must be added explicitly to the index again!
  • 18. The Index Working Copy Index Repository git add, git commit rm, mv ● Buffer between working copy and repository ● Describes what's commited next ● Shortcut: git commit -a
  • 19. Commit ● Changes stored in the index are written into the repository and get a new SHA1 checksum ● The HEAD-reference points to the new commit ● The last commit can be changed and re-committed using the --amend parameter, e.G. typos in the comment, missed changes to be commited etc. git commit --amend
  • 20. Show differences ● Between workspace and index git diff ● Between index and the last commit git diff --staged ● Between the workspace and the last commit git diff HEAD ● Between two commits git diff $commit $commit ● Between current branch and another one git diff branch_name
  • 21. Object references ● SHA1: d37f32a8058b2c4b5d1b1c55c4cab41611899cb3 ● Short SHA1: d37f32a ● Tags: v1.5.1 ● Local branch: master ● Remote branch: origin/master ● Checkout: HEAD ● Last Fetch: LAST_FETCH ● Previous Head: ORIG_HEAD
  • 22. Object references ● Parents: Name^, Name^^^, Name~10, Name^2, … ● What was yesterday? Name@{yesterday} ● What was on ...? Name@{1 June} ● What was … days before?Name@{3} ● What happened since...? --since=“2 weeks ago“ ● What was until ...? --until=“1 week ago“ ● Who has...? --committer=pattern ● What was between...? name1..name2
  • 23. Show me the commit ● Prints the diffs in a commit ● Shows diffs as well as statistics ● git show ● git show --stat ● Can be used with all object references
  • 24. Reset ● git reset modifies different elements: ● Variant 1: --hard The HEAD, the index and all local modifications in the workspace will be erased! ● Variant 2: --soft The HEAD will be overwritten. Previous commits will change to „changes to be committed“ ● Variante 3: --mixed (default) The HEAD and the index are overwritten ● The HEAD is just a reference to a specific commit
  • 25. Logs ● Shows the commit logs ● git log ● git log -10 ● Can be used with all object references ● git log -3 master@{15 July} ● git log --author=Max Mustermann ● git log --grep=pattern
  • 26. Search in files ● git provides a grep integration ● MUCH faster than standard grep git grep -e pattern -- some/file git grep -e pattern branch -- some/file
  • 27. Tags ● Tags are named references to commits ● There are annotated and lightweight tags ● Creation of a tag ● Lightweight: git tag <name> ● Annotated: git tag -a <name> -m „message“ ● Show all tags: git tag
  • 28. Create and change branches ● Branches are references to commits ● The default-branch is called master ● Create: git branch name [commit] ● Change: git checkout name ● Create and change: git checkout -b name ● The HEAD will be adapted accordingly
  • 29. Delete branches ● Branches can be deleted every time ● To delete a merged branch git branch -d branch_name ● To delete a non-merged branch git branch -D branch_name
  • 30. Show all branches ● Local ones git branch ● Remote ones git branch -r ● All branches git branch -a ● All non-merged branches git branch --no-merged
  • 31. Conflicts and merging ● Merge as many branches as you want at the same time git merge branch_a branch_b ● Merged branches can also be deleted ● Conflict markers indicates auto-merge problems ● Show with git status or git mergetool ● Use editor or mergetool to fix the conflict ● Stash the resolved conflict on the index ● Do a commit
  • 32. Cherry-pick ● Sometimes you only want to merge specific commits into another branch ● Git allows this cherry picking git cherry-pick <commit>
  • 33. Rebase ● Alternative to git merge ● Simple rebase pushes the branch onto the HEAD git merge master test git rebase master test f e' e d' e d d master c master c b b a a
  • 34. Interactive rebase ● git rebase -i master ● Handles multiple commits: f t(e+f) master ● delete e ● ignore d s(d) ● edit c ● squash together b b ● You can squash multiple commits a into one to have a clean history
  • 35. Remote Branches ● Clone creates a new local branch within a namespace: remotes/origin/<branch name> ● Default-name for remote server is origin ● Can be changed using git remote ● Checkout a remote branch using git checkout -b <remote_name>/<branch> ● Remote branches are Tracking Branches
  • 36. Adding remotes ● Unlimited number of remotes ● Modifications with git remote ● Typing git remote will list all remotes ➔ Team members can add other team members remotes for easy code exchange
  • 37. Pull the changes ● Tracking-branches know the SHA1 from the remote since the last pull ● Changes are fetched using git fetch remote:branch ➔ Note, these changes are not merged yet! ● Shortcut: Do a pull git pull remote:branch = git fetch + git merge
  • 38. Provide your changes ● Store the commits on a central repository server ● Not all local branches must be pushed → private stuff keeps private! git push remote:branch ➔ NEVER change the history of distributed changes using rebase!
  • 39. Stashing ● Common problem: ● Current work must be pushed asside but the changes shouldn't be commited yet ● Changes in the workspace/index must be transfered in another branch ● Solution: The index and changed files are cached and the workspace and index is resetted git stash save „description“ git stash apply git stash pop # apply and drop
  • 40. Stashing episode II ● Advantage: Stashing indexes the files and write them into the reflog ● Even if these changes are never commited, you can get them back git stash list git log stash@{10} git show stash@{26} git checkout -b old_work stash@{32} ● Use stashes simply like branches ➔ The reflog exists independent from the commits
  • 41. Blame ● Problem: You don't know who implemented the code snippet ● Solution: git blame -- file shows a list of changes for a file and when and who modified it
  • 42. Q&A