DEV Community

Cover image for How to Pull from a Remote Repository
Cherrypick14
Cherrypick14

Posted on

How to Pull from a Remote Repository

Suppose you're working on a project with other developers. The first thing to do is to create a repository where all the workflow will take place. Since y'all are gonna contribute to the repo, you have to understand the git tools. Someone from the team has made some changes to the repo, how do you stay updated..? Instead of zipping up files and creating more confusion, all you need to do is pull their changes into your local repository.

How to pull the changes:

  1. Navigate to your Git repo folder in your chosen terminal.
  2. Then run a git pull command.

So git pull is usually a combination of git fetch + git merge
It basically involves fetching upstream changes and syncing them with the local ones.

When should I use git pull?

  1. Before you start working ~ to stay updated with the latest changes.
  2. Before you push anything.

Fetching the Changes:
git fetch gets to download the latest remote repo changes.
git merge now merges those changes into your local codebase.

And what if I want to review the changes first and not merge the code immediately..? ~ Just do a git fetch other than git pull.
You'll get to proceed as per the steps listed in the ~ How to pull the changes. The difference comes in the 2nd part, instead of running a git pull command, run git fetch.

Top comments (0)