This content originally appeared on DEV Community 👩💻👨💻 and was authored by Heru Hartanto
When I was working, I accidentally put package.lock.json and yarn.lock.json in a commit, I just notice this mistake in the last minutes before I submit merge request.
How I can away with this situation
// remove package.lock.json and yarn.lock.json from git
git rm —-cached package.lock.json
git rm —-cached yarn.lock.json
git add .
git commit
git push
The ‘—-cached’ is the magic, In simple explanation I keep package.lock and yarn.lock in my local machine because I still need those file, but I removed it from the index tracking git so it won’t appeared in git project
This content originally appeared on DEV Community 👩💻👨💻 and was authored by Heru Hartanto
Heru Hartanto | Sciencx (2023-02-01T23:15:49+00:00) How to remove unwanted files in a commit but still keep it locally. Retrieved from https://www.scien.cx/2023/02/01/how-to-remove-unwanted-files-in-a-commit-but-still-keep-it-locally/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.