Yelp Facebook LinkedIn YouTube Twitter Instagram

Classes available in-person (strict social distancing) or live online with an extended free retake period. See details.

Git

Pull From a Remote Repository: git pull & git fetch

Git Tips & Commands

After someone else makes changes to a remote repo, you can download (pull) their changes into your local repo.

Pull Changes from a Remote Repo

1. In your terminal (Terminal, Git Bash, or Windows Command Prompt), navigate to the folder for your Git repo.
2. Run the following command:

git pull

NOTE: If you get a message about entering a commit message and don't know how to get out of it, you're in Vim (a Unix command line editor). To exit, press : to enter command mode, then q for quit, and finally hit Return (Mac) or Enter (Windows).

When to Pull

It's a good idea to pull:

  • before you start to work (so you have the latest changes)
  • before you push (in case something has changed while you worked)

Fetch Changes from a Remote Repo

When you do a git pull, behind the scenes git is doing git fetch (which downloads the latest changes from the remote repo) and then git merge (which merges them into your local codebase). If you don't want to merge the code immediately (you may want to review the changes first), you can do a git fetch instead of git pull.

1. In your terminal (Terminal, Git Bash, or Windows Command Prompt), navigate to the folder for your Git repo.
2. Run the following command:

git fetch

3. Now that you've downloaded the latest changes, you can compare your local branch to them. Assuming your on the master branch, you'd run the following command:

git diff master origin/master

NOTE: If you're working on a different branch, change master (in both places) to your branch name.

Go Beyond Git

We offer the best coding courses and bootcamps for students at all levels of experience. Classes are hands-on and students receive workbooks with step-by-step instructions through exercises with real-world applications. Check out our programming courses now: