brewly — Ch.4 · A secret in your last commit
Exercise 8 of 9
Before you start
Secrets do not belong in git
Passwords and keys must never be committed: anyone with the repository can read every old version.
You have not pushed yet, so you can still fix the commit itself.
git rm --cached <file> stops tracking a file but keeps it on your disk. Then list it in .gitignore (type it in the editor and save), stage that, and amend.
- git rm --cached <file>
- remove from git, keep the file
- git add .gitignore
- stage the new ignore rule
- git commit --amend --no-edit
- replace the last commit
- git show --stat HEAD
- which files are in the commit now?
You can reopen this any time with “Lesson”.
.gitignoreEdit the file, then save.
Graph
- 6e8d9e3 Prepare card paymentsHEAD → main
- 1354d06 Add menu pageorigin/main
- 619eb3b Style the order button
- 5fc44ac Initial commit