Pulling from remotes

Git intermedio

George Boorman

Curriculum Manager, DataCamp

Remote vs. local

local and remote branches where the remote branch has more files and subdirectories

Git intermedio

Collaborating on Git projects

data synchronizing between five local branches and the remote branch

Git intermedio

Fetching from a remote

  • Fetch from the origin remote
git fetch origin
  • Fetch all remote branches

  • Might create new local branches if they only existed in the remote

  • Doesn't merge the remote's contents into local repo

Git intermedio

Fetching a remote branch

  • Fetch only from the origin remote's main branch
git fetch origin main
From https://github.com/datacamp/project
 * branch                main     -> FETCH_HEAD
Git intermedio

Synchronizing content

  • Merge origin remote's default branch (main) into the local repo's current branch
git merge origin
Updating 9dcf4e5..887da2d
Fast-forward
 tests/tests.py | 13 +++++++++++++
 README.md     | 10 ++++++++++
 2 files changed, 23 insertions (+)
Git intermedio

Pulling from a remote

  • Local and remote synchronization is a common workflow
  • Git simplifies this process for us!

  • Fetch and merge from the remote's default (main) into the local repo's current branch

git pull origin
Git intermedio

Pulling a remote branch

  • Pull from the origin remote's dev branch
git pull origin dev
  • Still merges into the local branch we are located in!
Git intermedio

Git pull output

From https://github.com/datacamp/project
 * branch                dev     -> FETCH_HEAD
Updating 9dcf4e5..887da2d
Fast-forward
 tests/tests.py | 13 +++++++++++++
 README.md     | 10 ++++++++++
 2 files changed, 23 insertions (+)
Git intermedio

A word of caution

git pull origin
Updating 9dcf4e5..887da2d
error: Your local changes to the following files would be overwritten by merge:
       README.md
Please commit your changes or stash them before you merge.
Aborting
  • Important to save locally before pulling from a remote
Git intermedio

Let's practice!

Git intermedio

Preparing Video For Download...