I want to free some space on my machine and my git history is getting quite large. I have about 20 projects where I have the full history pushed to GitHub, so it would be enough for me to only keep the latest commit on my machine.
My two questions are:
How can I remove all commits but the latest one from a project, but only locally? I want to keep all history on GitHub and also push new commits in the future.
How would a command line script in Linux look like that goes over my project folders and repeats the action of only keeping the latest commit for each project. Here is what my folder structure with my projects looks like:
GWDG+mschmidh@UG-UFBW100-C393 MINGW64 /p/r/projects
$ ls
be-a-mapper/
biogeochem-processes/
climathur/
coding/
coding-examples/
Many thanks for your help!