So over the last few years I've really enjoyed learning and using Git for all of my coding projects. I love having a clear timeline of all changes and seeing when a change was made.
Well, I've opened up an old project that predates my Git use. I essentially have a list of folders for each 'commit' I made over time. All together I have over 70 versions. I want to easily store this project while also keeping all of the steps without wasting an atrocious amount of space.
Is there an automated way of doing this? What I am wanting to automatically do is essentially the following:
Folders:
- '2013_08_01'
- '2013_08_04'
- '2013_08_12'
- ... and many many more (*~70)
To import into a Git repo (single branch):
- Base commit A (+ note of date) of '2013_08_01'
- Commit B with changes (+ note of date) of '2013_08_04'
- Commit C with changes (+ note of date) of '2013_08_12'
- ...
Without doing this manually, what would be a fast way of accomplishing this? All of the folders are on the same local disk.
Here's a bash script I threw together that should do the job:
Run it as:
You could use
mvinstead ofcp, but I have heard that the/.syntax doesn't work withmv. (Also usingcpwill leave the original files in the unlikely event that something goes wrong.)Another thing to keep in mind is that depending on the type of project, there may be some files that you don't want tracked by Git. (E.g. binaries.) You may want to add a
.gitignorebefore importing the old copies; if so, modify the script accordingly.Thanks to @Vampire for pointing out a couple bugs in the original version of my script.