A week ago, I made a Git repository on NotABug.org. Then I noticed I forgot to select a license. Hmm, looks like you can't select a license once it's created. So I deleted the repostory and recreated it, this time choosing a license. Today it hits me that, unlike my other repository, all of my files are in the root instead of being in a folder called src, there's no license, and no readme.md. Something must have gone wrong because the repository previously existed. I think I can rebase and add a new first commit to add the missing license, readme.md, and the src folder. But if I move the source code into the src folder, the history will be lost. Git experts, how do I move those files without losing this week's history? Bear in mind that I don't use the command line (I used to, though!), but Fork.
git mv does not let you keep the history. I mean, it's still there, but not attached to the file in the new location.
Yes, but that's misleading. The history isn't gone, but the moved file will be considered a different file and not be linked to the previous history.
On GitHub at least, a file move looks like this: Yeah, the whole file history isn't shown in one place but the move is recorded, and you can use that to go further back. It seems that 'git log --follow' can also detect moves and show the full history, some GUIs may do this automatically. Rewriting history so the previous commits use the new filename is inadvisable, if it's even possible.
It's inadvisable if you're working with others on the same repository, but as I'm the only contributor right now, there's no harm. Luckily, it is possible using git-filter-repo. After finding readable documentation on how to use it to do what I want, I solved my problem.
Does that also fix the files themselves to refer to the changed name or do you now have a bunch of broken builds in your history?
It doesn't touch the files themselves, no. If all I wanted to do was place all the files in /src, I wouldn't need to change anything. However, I took the opportunity to place the gost08-related files in /src/zone08, so I do need to fix their #include directives.