3

Before I found the power of git I used to take snapshots of my code and store on my server.

I have an existing git repo for a project I am working on, but I have found some older version on my server that I want to update into git.

Is there a way I can retrospectively add these old version to the repo, keeping the correct sequence development?

jub0bs
  • 60,866
  • 25
  • 183
  • 186
Andys
  • 43
  • 6
  • This might help: [How do I make a Git commit in the past?](https://stackoverflow.com/questions/3895453/how-do-i-make-a-git-commit-in-the-past). – Martin Sep 02 '15 at 11:03

2 Answers2

1

I would recommend to do it the other way around. Put the latest of your snapshot sources into a git repo and try to apply all the commits from your current repo. Maybe using git format-patch. If the state of the old source and the first commit of your current repo do not differ to much this should work.

Josh Crozier
  • 233,099
  • 56
  • 391
  • 304
NaN
  • 7,441
  • 6
  • 32
  • 51
1

If you haven't published the repository, then create commits out of your snapshots and rebase your branch on top of them.

If you have published the repository and your collaborators don't mind switching over to an entirely new rebased branch (which might require them to rebase their own changes), then you can do the same.

If you have published and you don't want to disturb anyone but still would like to add those commits for documentation purposes, you can create a new root branch separately. At this point you have a choice: leave it at that, or "attach" the branch to your main branch. By "attach", I mean "create a commit with both branches heads as parents, with the state of the main branch". You might call it a "merge commit", but obviously the branches aren't really "merged" since the main branch already reflects the appropriate state. For this, I'd point you to commit-tree and write-tree. This makes the commits easier to discover, though might be confusing to some. You'll probably want to backdate them, too.

Depending on what you choose, I encourage you to ask a new question or refine your current question.

tne
  • 7,071
  • 2
  • 45
  • 68