By the end of this page you will know exactly what GitHub is, what push, fetch, and pull really do, and why a "rejected" push is git protecting you, not scolding you.
For eight lessons, everything happened on your Mac. Your photo album of save points lives in your project folder, and it works perfectly with the WiFi off. Time to meet the second word in the course title.
So they are two different things that happen to share a name:
| git | GitHub | |
|---|---|---|
| What it is | a program on your Mac | a website |
| Works offline? | yes, completely | no, it lives online |
| Its job | keeps your album of save points | hosts copies of albums so teams can share them |
| Who owns it | no one, it is free open source | Microsoft |
GitHub also stacks collaboration tools on top of the hosting: code reviews and shared to-do lists, which you will meet in lessons 10 and 11. And GitHub is not the only site like this. GitLab and Bitbucket do the same job. Learn one and you can use them all, because underneath they are all just hosting git albums.
Here is the part that surprises people who know Dropbox or iCloud Drive. Those tools often keep the real files in the cloud and leave little placeholder stubs on your disk. Git does not work that way at all.
Your Mac holds the entire album: every photo, every sticky note, the whole chain back to the very first save point. GitHub holds its own entire copy of the same album. Two complete albums, one on your desk and one in the cloud. If GitHub vanished tomorrow, you would still have everything. If your Mac caught fire, GitHub would still have everything. That is the whole point.
These are the real save points from your own project, shown living in both places at once:
Same beads, same sticky notes, same green main bookmark on both sides. The only question left is how the two albums stay matched. That takes exactly three verbs.
You take new photos on your Mac, so sometimes your album is ahead. Teammates upload their photos to GitHub, so sometimes the cloud album is ahead. Three moves keep things in sync: upload mine, download theirs to look, and download theirs and blend them in.
| verb | in plain words | does it touch your work? |
|---|---|---|
| push | upload my new photos to GitHub | no, only GitHub's album changes |
| fetch | download their new photos so I can look | no, your files stay exactly as they were |
| pull | download their new photos and blend them into mine | yes, it is fetch plus the merge from lesson 6 |
Because pull ends in a merge, it can occasionally raise a conflict. Remember: a conflict is git asking you a question, not an error. You already learned how to answer it, line by line, and nothing gets lost while you decide.
git clone URL.Q. What is the difference between fetch and pull?
Sooner or later you will push and see this. It looks scary. It is not.
git push To github.com:you/your-project.git ! [rejected] main -> main (fetch first) error: failed to push some refs to 'github.com:you/your-project.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. If you want to integrate the remote changes, use hint: 'git pull' before pushing again.
Translated into album language: "GitHub has photos you have not seen yet. Download them first." Probably a teammate pushed while you were working. Git refuses to let your upload overwrite save points you never looked at. That is the safety rule: push will never silently destroy work on the other side.
The fix is two commands, and you already know both:
git pull # download their new photos and blend them with yours Merge made by the 'ort' strategy. git push 4e19c72..8c2d1aa main -> main
Pull, then push. If the pull raises a conflict question, answer it the way lesson 7 taught you, then push. This message is not an error. It is a seatbelt clicking shut.
Check yourself: your push was just rejected. What happened, and what do you do?
So if syncing photos has never frightened you, syncing save points should not either. Push is upload. Fetch is download to look. Pull is download and blend. The vocabulary is new, the habit is one you already have.
You do not need an account, a password, or even Terminal for this one. GitHub shows public albums to anyone, and you can already read every part of the page.
Open your browser and visit a famous public repo, for example the album of git itself:
github.com/git/git # yes, git keeps its own history in git
Now find your three old friends on the page:
1. The file list in the middle is the latest photo: the project exactly as it looks at the newest save point.
2. The commits count near the top, click it, is the photo album: the whole chain of beads, newest first, just like git log.
3. The branch dropdown on the left is the box of bookmarks. On this repo it says master, the older name for the default bookmark, which the git project still uses. Pick a different one and the file list jumps to where that bookmark is clipped.
Nothing on this page is new to you. It is the same album, the same chain, the same bookmarks, just drawn by a website instead of your Terminal.