When you forget to write in .gitignore and commit "It's okay if you add it to .gitignore ..." Are you misunderstanding? Like me .. sweat
Files managed by Git will not be removed just by adding to .gitignore later, so I will write a countermeasure in such a case.
$ git rm --cached [File name you want to exclude]
After that, be sure to add the files you want to exclude to .gitignore
.
Note:
Be sure to add --cached
! !!
If you do not add it, the entire file will be deleted.
$ git rm [File name you want to delete]
$ git rm -r [Directory you want to delete]
When I started using Git, I forgot it several times and committed it, and I checked it each time, so I will keep it as a memorandum.
I hope it helps those who are in the same situation.
Recommended Posts