AI Hints
Home›Git & GitHub Tutorial›Project: Rescue Mission
Git & GitHub · Lesson 124 of 144

Project: Rescue Mission

Fixing a messy repository.

⏱ 2 min read▶ Video at 2:15:21🎓 Free
Watch this lesson in the Git & GitHub courseWatch on YouTube ↗Full Git & GitHub course

In this last project, a repository is in a mess, and it's your job to rescue it. There are three problems. Unfinished work in the way. A secret key committed by accident. And a commit on main that should be on a branch. Nothing has been pushed yet, so we can fix it all.

Project: Rescue Mission
From the video: Project: Rescue Mission
  • Unfinished work in the way
  • A committed secret
  • A commit on the wrong branch

Investigate first

Always start by looking. Status shows a modified home page, our unfinished work. The log shows a commit, add shop page, on main, not yet pushed. And show dash dash stat reveals that commit includes a file called dot ENV, our secret key.

git
git status --short
 M index.html
git log --oneline -n 2
bb1d183 (HEAD -> main) Add shop page
f63a17a (origin/main) Link to about page
git show --stat --oneline HEAD
bb1d183 (HEAD -> main) Add shop page
 .env      | 1 +
 shop.html | 1 +
 2 files changed, 2 insertions(+)

Step one: shelve the unfinished work

The half-written blog post isn't ready, and it would get in our way. So we stash it, with a message. Status is clean, and we can work safely.

git
git stash push -m "half-written blog post"
Saved working directory and index state On main: half-written blog post
git status --short

Summary

Investigate with status, log and show before changing anything. Then shelve unfinished work with git stash. Next, removing the secret.

Key takeaways
  • status, log, show first
  • git stash push -m
  • A clean place to work
Next up: Project: Removing the Secret — before it is pushed