Adding older versions of code to git repo

I have a git repository for my project, and my first commit was in v1.2. Before git, I used daily snapshots of my code to keep it safe. Now I would like to add all the snapshots that I have in the repo, also starting from version 3.0, but I already have quite a few commits over 1.2. So what is the best way to continue? Should I just take pictures one by one and add tags? Or should I create another branch, perhaps for all these snapshots? Or maybe start a new repo with v0.3 and fix all the snapshots, and then somehow combine the repo with the old version 1.2?

+4
source share
2 answers

Ben's answer is, of course, a good way if you haven’t done this public public community.

If, on the other hand, you already published your current repository and, therefore, do not want to transfer its root commit to the previous work, I would suggest something disjoint. I personally will be tempted to just create another branch in the repository called "legacy", or some of them, start it with a new root commit using the very first snapshot and transfer all the others on top of it. Presumably, the main use here is simply archiving this work and possibly checking it or distinguishing it from it at some point - and you can do it all, even if the story is a bit strange:

# No commits in common! - o - o - o - o - o (master) - o - o - o (legacy) 
+5
source

You can git filter-branch --parent-filter transfer your work to old versions, but this will cause problems if you share your repo with anyone else. Everyone will get a new SHA. There really is no way to avoid this: the parents (back to the original version) are part of the SHA of each revision. If this does not bother you (if this is your personal repo), then go for it.

An example is provided in git help filter-branch :

+4
source

Source: https://habr.com/ru/post/1340496/


All Articles