Snapshots, not diffs
Git and version control
A commit is a snapshot of the whole tree plus a pointer to its parent. A branch is a movable label on one commit. Once you hold those two facts, branching, merging and rebasing stop being magic.
Commits and branches
Git stores content by hash, so a commit is immutable and cheap to compare. A branch is just a file containing a commit id — creating one does not copy your work, which is why branching is free.
Merging joins two histories at a new commit. When both sides changed the same lines, git cannot choose and asks you to; the conflict markers are the two versions, not git failing.
Remotes are just another path
A remote is a URL or a filesystem path with the same object database. `push` sends commits your remote does not have; `pull` fetches and merges. Nothing is special about GitHub at this level.
This is why a bare repository on a server is enough to collaborate — and why 'it is on my machine' is a claim about your local labels, not about shared truth.
Commands in this lesson
Every one of these runs in the sandbox — no real account, no real bill.
| Command | Why |
|---|---|
git checkout -b feature | Create a label and move to it — one command, no copying. |
git add f.txt | Stage the version you mean to commit; the working tree keeps changing. |
git commit -m "feature change" | Freeze that snapshot with a message future-you will need. |
git merge feature | Join the histories; conflicts are where both sides edited the same lines. |
git remote add origin /srv/git/app.git | Point a name at a shared object store. |
git push origin main | Publish commits the remote does not have yet. |
Now do it
Reading the model makes the first attempt faster. Only the lab makes you able to do it.
- Open the lab
Git Basics: Init, Stage, Commit
Beginner · 18 min · members
- Open the lab
Git: Branch, Merge & Resolve a Conflict
Intermediate · 25 min · members
- Open the lab
Git: Publish to a Remote
Intermediate · 20 min · members
Git and version control · OphirCloud Academy · all lessons