Project: Finishing the Rescue
Branch, push, restore.
Last problem. The shop commit is on main, but our team only allows changes through pull requests. Let's move it to a branch, push it, and bring back our unfinished work.

- The shop commit is on main
- It belongs on a branch
- Then restore our work
Move, push, restore
Git branch shop labels the commit. Reset main back to origin main, where GitHub has it. Switch to shop, and push it, ready for a pull request. Back on main, git stash pop brings back the blog post. Every problem is solved.
git branch shop git reset --hard origin/main HEAD is now at f63a17a Link to about page git switch shop Switched to branch 'shop' git push -u origin shop To https://github.com/sam/my-site.git * [new branch] shop -> shop branch 'shop' set up to track 'origin/shop'. git switch main Switched to branch 'main' Your branch is up to date with 'origin/main'. git stash pop On branch main Your branch is up to date with 'origin/main'. Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: index.html Untracked files: (use "git add <file>..." to include in what will be committed) .env no changes added to commit (use "git add" and/or "git commit -a") Dropped refs/stash@{0} (f9d409a87d48c6260c500cf9ac350e9302889cf1)
The final check
One last look. The graph shows main matching GitHub, and the clean shop commit on its own branch. Status shows our unfinished blog post, and dot ENV as untracked. That's because the new ignore rule lives on the shop branch, until it's merged. Until then, just be careful not to add it. And l s shows the secret is still safely on disk, where it belongs.
git log --oneline --graph --all -n 3 * 373488f (origin/shop, shop) Add shop page * f63a17a (HEAD -> main, origin/main) Link to about page * ef9c947 Add basic styles git status --short M index.html ?? .env ls -a . .. .env .git about.html index.html style.css
Summary
You investigated, stashed, removed a secret, moved a commit, and restored your work. That's a real rescue. Next, a real open source contribution, from start to finish.
Key takeaways- Investigate first
- Fix one problem at a time
- Check the result