Git Workshop
POSTS

Bob: pulling

Lab

  • Bob doesn’t want to write anything today, but he is interested in reading what Alice has added to the story. First, he will check his own repository and ensure he is using the main branch
cd
cd bob/book
git status
git checkout main
  • Alice has told him to update the remote reference to point to the new bare repo, so Bob starts by checking the old value
git remote
git remote get-url origin
Yes, definitively he has to change the value of the origin repo, but he doesn't want to loose the current one, so he renames it
git remote ██████ origin alice
git remote

Solution

git remote rename origin alice
git remote

  • Now Bob can safely create the new remote reference
git remote add origin ../../central.git
git remote
  • Not being completely sure of how to proceed, Bob wants to check the content of the central repo before merging it with its own work
git fetch origin main
  • The short-lived ref FETCH_HEAD can be used to refer to the data retrieved from the remote origin
git diff FETCH_HEAD
Ok, looks like Alice didn't modified anything already existing and just added the new chapter, so Bob merges it with `main`. If he had new it, he would had used the `pull` command instead to combine both operations into one
git merge F████_████ -m "Merged new content written by Alice"

Solution

git merge FETCH_HEAD -m "Merged new content written by Alice"

–

  • Another fantastic job, Bob thinks. And he leaves the workspace
cd ../..

Diagrams

This diagram was created by @nikki.and.chris.

Diagram showing commands to move files between areas

    Quick access

    1. Introduction
    2. Alice: repo initialization
    3. Alice: first commits
    4. Alice: moving through the timeline
    5. Alice: basic branching
    6. Alice: merging without conflicts
    7. Alice: merging with conflict resolution
    8. Alice: tagging
    9. Bob: cloning repositories
    10. Bob: pushing to origin
    11. Alice: merging and log format
    12. Alice: centralized repository creation
    13. Bob: pulling
    14. Bob: recovering from errors with the reference log
    15. Bob finds the author of a typo
    16. Alice: amending commits
    17. Alice: history simplification
    18. Alice: cherry picking changesets
    © Git Workshop 2023