Skip to content
jsworkbench.
Learning path
Advanced18 min

Feature ownership and branch-based work

Understand the idea

A fork is your copy of the class's shared starter. The branch you add is where your work lives.

The idea

Forking writes a second whose history starts as a copy, with pointing at the shared starter. That starter is the one your teacher marked for the class. It is class or public so every classmate can fork the same repo.

What changes

git fork their-slug creates your repository and sets forked_from to the shared starter. Their labels are copied. The next commit on your branch moves only your label. Classmates fork the same starter; they do not fork your copy for the standard path.

Starter and fork
RepositoryWho writes itWhat origin means
Shared class starterThe teacher (maintainer)Nothing, until someone forks it
Your forkYouThe shared starter you copied
A branch on the forkYouA label on your copy only

The command

In the classroom, the teacher saves a starter repository. Then run git fork with that slug. git switch -c class-notes, edit README.md, git add README.md, and git commit -m "add fork notes".

The mistake

Check your graph

Your fork shows the starter's old commits plus the new one on class-notes. The starter's main label has not moved.

Your repository

Fork the teacher's shared starter repo, then commit on a branch that the starter does not have.

  1. Step 1

    Fork the class starter

    Use the shared starter your teacher designated, or greeting-kit if you are practicing alone. Every classmate forks that same repository — not each other’s forks.

  2. Step 2

    Branch on your fork

    The shared starter’s main stays put. Your work is on this branch of your fork.

  3. Step 3

    Write your change

    In the editor, add a line to README.md: Notes from my fork.

  4. Step 4

    Stage and commit

    This commit exists only on your fork.

  5. Step 5

    Save it

    The graph shows the new commit on class-notes.

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 does a fork copy?
02Where should the feature commit land?

Ready to call this one understood?

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

Sign in to save progress
Next lesson