Skip to content
jsworkbench.
Learning path
Foundations18 min

Why version control exists

Understand the idea

A folder of FINAL_v2_actualFINAL copies is not a history. It is a pile of guesses.

The idea

A folder of renamed copies does not tell you which file came from which. A names one whole snapshot and points at the snapshot it grew from. That chain is the history a team can share.

What changes

Nothing in the working files has to change for the idea to matter. What changes is that the group stops guessing. The holds the chain. People still edit files, but the saved history is no longer a second copy of the folder sitting beside the first.

Copies versus history
HabitWhat you can answerWhat you cannot
FINAL_v2 foldersWhich file looks newestWhich edit came from which
A commit chainWhat the folder was, and what it grew fromNothing about parentage
A chat log of changesWho claimed to edit somethingThe exact bytes at that moment

The command

You do not need a command to see the problem. Open the terminal on the next lesson and create a repository. Until then, read git log --oneline --graph as the sentence this track is building: each line is a named snapshot, and the graph is how they connect.

The mistake

Check your graph

When you do create the repository, the graph should show one initial commit and a main label. That single node is already more history than a pile of renamed folders.

Your repository

Version control exists so a team can name a snapshot, see who changed it, and return to it without keeping extra copies of the whole file.

  1. Step 1

    Look before a repository exists

    A folder with no repository has nothing to return to. Run status. If you have not created a repository yet, Git says this is not a repository.

  2. Step 2

    The next lesson creates the history

    Creating the repository is the first real snapshot. Continue to Repositories and the three states and use the create form there.

The editor edits the working tree. Start a repository and the files appear here.

Follow the steps. Each command step can be placed in the terminal. Edit files in the editor, then stage them.
Supported command reference
  • init
  • add <path> | add .
  • commit -m "message" | commit --amend -m "message"
  • status
  • diff | diff --staged
  • log | log --oneline | log --graph | log --oneline --graph
  • show [ref]
  • branch | branch <name> | branch -d <name>
  • checkout <ref> | checkout -b <name> | switch <name> | switch -c <name>
  • merge <branch>
  • rebase <branch> | rebase -i <branch> | rebase --edit-todo <pick|drop|reword> <hash> [message] | rebase --continue | rebase --abort
  • cherry-pick <ref>
  • reset --soft <ref> | reset --mixed <ref> | reset --hard <ref>
  • revert <ref>
  • stash | stash list | stash pop | stash apply
  • restore <path> | restore --staged <path>
  • remote | remote add <name> <repo-slug>
  • clone <repo-slug> | git clone <repo-slug> | git fork <repo-slug>
  • fetch [remote] | pull [remote] [branch] | push [remote] [branch] | push --force [remote] [branch]
  • blame <path>
  • reflog
  • tag | tag <name> [ref] | tag -d <name>
  • bisect start | bisect good [ref] | bisect bad [ref] | bisect reset
  • config <key> <value> | config --list
  • write <path> <text> (workbench: edit the working tree)
  • issue new "title" | pr new <source> <target> "title" | review "comment" | review --request-changes "comment"

Commit graph

No commits yet. git init creates the first one.

Quiz

A quick check for understanding. Retry as often as you like; your learning path stays open.

01What problem do named snapshots solve?
02Why is FINAL_v2 a weak history?

Ready to call this one understood?

Mark this lesson complete to earn 100 XP. You can always revisit it.

Sign in to save progress
Next lesson