Skip to main content

Capstone — Ship Campus Library v1.0

Time for the real thing. This challenge chains everything you learned into one small project. Plan for about one hour. If you get stuck, the answer to every step is already in the pages you've read.

Goal

By the end, your repository should have multiple feature branches merged into main, one resolved conflict, a stashed-and-restored change, a v1.0 tag, and a clean history.

Step 1 · Open the Notebook​

Create the project and your first commits:

Start Campus Library
mkdir campus-library
cd campus-library
git init

Create the base files. Give each one a line or two of simple content.

Create the skeleton
nano index.html # <h1>Welcome to Campus Library</h1>
nano README.md # Campus Library — the college library app
nano .gitignore # node_modules/
First commit
git add .
git commit -m "Create Campus Library skeleton"

Step 2 · Four Friends, Four Features​

Each feature gets its own branch. Create them all from main:

Create the feature branches
git switch -c feature-login
git switch main
git switch -c feature-catalog
git switch main
git switch -c feature-membership
git switch main
git switch -c feature-search

Now merge two of them the simple way (no conflicts expected):

Merge feature-login into main
git switch main
git merge feature-login
Remember

Each branch is its own notebook copy. Merging is just handing the pages to the librarian to combine. This is your daily habit — status, add, commit, pull, push.

Step 3 · Create a Conflict on Purpose​

This is where the skills from Exercise 3 come back. On feature-catalog, write a line in a shared file. Then change the same line on main. Merge and resolve it:

Set up the clash
git switch feature-catalog
nano catalog.html # write: Best book: Sherlock Holmes
git add .
git commit -m "Add catalog book"

git switch main
nano catalog.html # write: Best book: Dune
git add .
git commit -m "Change catalog book"
Merge and watch the conflict appear
git merge feature-catalog
CONFLICT (content): Merge conflict in catalog.html

Open catalog.html, remove the <<<<<<< / ======= / >>>>>>> markers, keep both books, then finish:

Resolve and finish the merge
git add catalog.html
git commit -m "Resolve catalog conflict"

Step 4 · Stash an Emergency Fix​

While working on feature-search, the librarian needs you on main right now. Your search work is half-finished:

Put the messy work in the drawer
git switch feature-search
nano search.html # start writing the search page
git stash
Deal with the emergency, then get your work back
git switch main
git stash pop

Step 5 · Undo Something​

Accidentally delete README.md and commit the mistake — then rescue it like a pro:

Oops and rescue
git rm README.md
git commit -m "Remove README (oops)"
git checkout HEAD~1 -- README.md
git add .
git commit -m "Restore README"
Remember

git checkout <hash> -- <file> restores a file from history. That's the time travel superpower.

Step 6 · Merge the Rest and Tag v1.0​

Bring the remaining features in and mark the milestone:

Finish the remaining features
git merge feature-membership
git merge feature-search
Mark the release
git tag -a v1.0 -m "First release of Campus Library"
Admire the final diary
git log --oneline --graph

You should see main with all four features merged, the conflict-resolution commit, the rescue commit, and a straight-ish history.

Step 7 · Check Yourself​

  • git init + first commits
  • 4 feature branches created
  • 2 merges with no conflict
  • 1 conflict resolved
  • git stash + pop
  • restore a deleted file
  • v1.0 tag created
  • git log --graph read

Done! You've shipped Campus Library v1.0 — and you now know enough Git to work on almost any real project. If any term felt fuzzy, check the Glossary. To see how real teams pick their branching rules, read Branch Strategies.