OphirCloud Academy

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.

mainfeaturemerge
Branches are labels on commits, so creating one copies nothing. A merge is a new commit with two parents.

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.

CommandWhy
git checkout -b featureCreate a label and move to it — one command, no copying.
git add f.txtStage 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 featureJoin the histories; conflicts are where both sides edited the same lines.
git remote add origin /srv/git/app.gitPoint a name at a shared object store.
git push origin mainPublish 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.

  • 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

    Open the lab

Git and version control · OphirCloud Academy · all lessons