Back to Learning Path

Step 10: Git Pull - Stay Updated

When working with a team, others will make changes to the repository. Use git pull to download their latest changes to your computer.


What is Git Pull?

git pull fetches changes from GitHub and merges them into your current branch. It keeps your local code in sync with the remote repository.

Simple analogy:

Like clicking "Refresh" on a shared Google Doc to see what others have written. You download the latest version.


How to Use Git Pull

Basic Usage

Make sure you're in your repository folder, then:

bash
git pull

This downloads changes from GitHub and updates your current branch.

Pull from Specific Branch

You can specify which remote and branch to pull from:

bash
git pull origin main

When to Pull

  • Before starting work — Always pull first to get the latest changes
  • After team makes changes — When someone else pushes to GitHub
  • Working on shared branch — Keep your copy in sync multiple times a day
  • Before pushing — Pull first to avoid conflicts

Typical Daily Workflow

  1. git pull — Get latest changes
  2. Make your changes to the code
  3. git add . — Stage changes
  4. git commit -m "message" — Save changes
  5. git pull — Check for new changes again
  6. git push — Upload your changes

Try It Yourself

Practice with your own repository:

  1. Make a change on GitHub directly (edit README)
  2. Run git pull in your local repository
  3. See the changes appear in your local files!

Handling Merge Conflicts

Sometimes you and a teammate edit the same lines of code. When you pull, Git doesn't know which version to keep. This is called a merge conflict.

If you see a conflict:

  1. Open the conflicted file
  2. Look for special markers Git adds
  3. Choose which version to keep (or combine both)
  4. Remove the conflict markers
  5. Add and commit the resolved file

Tip: Conflicts are normal! They happen in every team. Don't worry — you'll get better at resolving them.

Pull vs Push

git pull

Download changes FROM GitHub TO your computer. Gets others' work.

git push

Upload changes FROM your computer TO GitHub. Shares your work.

Quick Summary

  • git pull downloads changes from GitHub
  • Always pull before starting work
  • Pull often to stay in sync with your team
  • Merge conflicts are normal — you can resolve them!