Reference: SVN → Git Rosetta Stone

ConceptSVNGit
RepositoryCentral server databaseLocal .git folder (full clone)
Get the reposvn checkout URLgit clone URL (gets full history)
CommitNetwork upload to serverLocal snapshot save
Publish(same as commit)git push (separate step)
Revision IDr1024 (sequential integer)a1b2c3d (SHA-1 hash)
BranchDirectory copy, O(N)Pointer creation, O(1)
Get changessvn updategit fetch + git merge (or git pull)
View historysvn loggit log --oneline --graph --decorate
Undo local editssvn revert FILEgit restore FILE (not git revert!)
Undo a commit(no equivalent)git revert COMMIT (new “reverse” commit)
Switch branchsvn switch BRANCHgit switch BRANCH
Who wrote this?svn blame FILEgit blame FILE

Reference slide. Press Down for more, Right to continue

Commits and pointers

  • Commits A, B, C, D are immutable snapshots
  • main is a pointer (label) to a commit; it moves forward
  • HEAD points to the current branch name
Pitfall #2: A branch is a pointer, not a directory copy. Creating one is almost instant and essentially free.

Diverged branches

  • main points to D; topic points to F
  • They share history A, B, C
  • HEAD is on main (that is where we are working)

This is the typical state before a merge.

Two separate graphs (2 min)

After git clone, your machine has its own DAG. The remote “origin” has its own.

Your machine

Remote “origin” (GitHub)

  • origin/main is a local pointer, not a live link
  • git status says “up to date” — it compares locally only, does NOT contact the server
  • Only git fetch / git pull actually talks to the remote
Don’t be fooled: git status can say “up to date” even when the remote is 50 commits ahead. Run git fetch first if you want the truth.

Press Down for a step-by-step example of the push/pull cycle.

Example: the push/pull cycle (1/7)

After clone: both machines are identical. Everything is in sync.

Your machine

Remote “origin” (GitHub)

main and origin/main both point to C. You and the remote agree.

Press Down to continue, Right to skip ahead

Example: the push/pull cycle (2/7)

Your colleague commits and pushes D. The remote moves forward.

Your machine

Remote “origin” (GitHub)

Your machine has no idea that D exists.

origin/main still points to C — that is where the remote was when you last fetched.

Press Down to continue, Right to skip ahead

Example: the push/pull cycle (3/7)

You commit E locally. git status says “ahead of origin/main by 1 commit.”

Your machine

Remote “origin” (GitHub)

The two graphs have diverged, but you do not know it yet.

git status thinks you are simply 1 commit ahead — it has no idea the remote also moved.

Press Down to continue, Right to skip ahead

Example: the push/pull cycle (5/7)

git fetch downloads D and updates origin/main. Your files are untouched.

Your machine

Remote “origin” (GitHub)

Now you can see the divergence. main is at E, origin/main is at D.

Press Down to continue, Right to skip ahead

Example: the push/pull cycle (6/7)

git pull merges D and E into a new merge commit M.

Your machine

M has two parents (D and E). Your work and your colleague’s work are combined.

Press Down to continue, Right to skip ahead

Example: the push/pull cycle (7/7)

git push succeeds. Both machines are back in sync.

Your machine

Remote “origin” (GitHub)

main and origin/main both point to M. Everyone has everything.

Reference slide. Press Right to continue

Reference: remote-tracking refs

Remote “origin”:

Your local repo after fetch:

After git merge origin/main (or git pull):

  • origin/main updates only on fetch (or pull, which fetches first)
  • You cannot commit directly to origin/main
  • git branch -vv shows tracking relationships

Reference slide

Reference: merge vs fast-forward

Fast-forward (topic is ahead of main, no divergence):

Before:

After:

No new commit is created. main pointer simply moves forward.

Merge commit (main and topic have diverged):

Before:

After:

M is a new commit with two parents.

Reference slide

Merge: combining histories

Two outcomes when you run git merge topic:

Fast-forward (no divergence): main pointer moves to the topic commit. No new commit created.

Merge commit (branches diverged): a new commit with two parents is created.

Pitfall #7: Unlike svn merge (which replays changes one at a time), Git merge combines two snapshots into one. The result is a new commit with two parents.