Pull
You might say
My teammate says they're done with their changes. How do I get their version onto my computer?
Download remote changes and integrate them into the current branchGit pull usually runs fetch and then merge or rebase. It updates the current branch with work from its configured remote branch. Check local changes and the active branch first so a convenient command does not create an unexpected integration.
When to use it
- Update a local branch from its remote
- Receive teammates' commits
- Synchronize before starting new work
- Bring remote changes into a clean working state
When NOT to use it
- Pull without checking which branch is active
- Use it with unresolved local changes
- Assume it only downloads files without integrating
- Resolve resulting conflicts by blindly choosing one side
Anatomy
☁️ New commits on remote repository GitHub
git fetch →
🗄 Local repositorydownload first, but don’t touch your files
git merge →
💻 WorkspaceNew code incorporated
The remote branch contains commits collaborators have pushed
Downloads remote commits and updates remote-tracking references without changing working-tree files
Fetched commits remain separate until you merge or rebase them.
Integrates fetched commits into the current branch; conflicts may occur here
After integration, the working tree reflects the updated current branch
Variants
git pull
git status && git pull
Check local changes before bringing in remote updates
git fetch
git fetch
Get remote updates, but don't merge them into the current branch yet
up to date
Already up to date.
This message means your current branch already matches the remote
Typical use cases
Start of day sync
$ git pull
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
Updating a3f9c21..e7b2d48
Fast-forward
index.html | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
Before a push
$ git pull
Auto-merging index.html
CONFLICT (content): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.
Resolve the conflict in the file, then run git add and git commit
Receive team changes
git clone
First setup: create a local repository from a remote one
📦 Downloads files and commit history
git pull
Ongoing work: bring remote commits into an existing local branch
📄 Fetches and integrates new commits
Update a long-lived branch
🏢💻
Work computer
git push
git push
☁️
GitHub
Remote repository
Remote repository
🏠💻
Home computer
git pull
git pull
Push committed work from one computer, then pull it into the other repository
Further reading