I use git for versioning. Just yesterday I was working on refactoring my Python code base. After adding a test I found that I had introduced a bug in one of project euler solutions. So I checked out a previous version offline, found the diff and went back to latest version and fixed the problem.
It was a bit after that I found a mess up had been done due to this. I use .gitignore to leave many of the unneeded files or WIP things out of git. I found that using checkout and going back to the latest version deleted some files which were not checked in. Now I am finding that a new repo that I keep in an ignored Folder is completed cleaned. It did not have much so far but still all is gone.
So I am confused about what is a good way to keep offline codebase intact in case there are many such folders/files that I do not want to check in? Also how to organize codebase on local for new projects? Just take backups on a drive?