Fetching Changes
Git fetch.
While you're working, your teammates push new commits to GitHub. Your computer doesn't know about them until you ask. Git fetch asks GitHub what's new, and downloads it, without changing your files.

- Teammates push new commits
- Your copy doesn't know yet
- git fetch downloads, safely
git fetch
Our teammate Alex has pushed a commit. We run git fetch. Git downloads it, and shows origin main moving forward. Now status says, your branch is behind origin main by one commit. But our files haven't changed yet. Fetch only looks, it doesn't touch.
git fetch From https://github.com/sam/my-site f63a17a..7893b97 main -> origin/main git status On branch main Your branch is behind 'origin/main' by 1 commit, and can be fast-forwarded. (use "git pull" to update your local branch) nothing to commit, working tree clean git log --oneline -n 2 f63a17a (HEAD -> main) Link to about page ef9c947 Add basic styles
Remote-tracking branches
Where did the new commit go? Into a special branch called origin slash main. It's your computer's memory of where main is on GitHub. Fetch updates it. Your own main stays put, until you decide to bring the changes in.
| key | value |
|---|---|
| main | your branch |
| origin/main | GitHub's main, as last fetched |
| git fetch | updates origin/main |
| Your files | untouched |
Summary
Git fetch downloads new commits into origin slash main, without changing your work. Next, bringing those commits into your branch.
Key takeaways- git fetch
- Updates origin/main
- Your files stay the same