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:
git pullThis downloads changes from GitHub and updates your current branch.
Pull from Specific Branch
You can specify which remote and branch to pull from:
git pull origin mainWhen 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
git pull— Get latest changes- Make your changes to the code
git add .— Stage changesgit commit -m "message"— Save changesgit pull— Check for new changes againgit push— Upload your changes
Try It Yourself
Practice with your own repository:
- Make a change on GitHub directly (edit README)
- Run
git pullin your local repository - 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:
- Open the conflicted file
- Look for special markers Git adds
- Choose which version to keep (or combine both)
- Remove the conflict markers
- 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 pulldownloads 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!