Vladimir Nikishkin
Vladimir Nikishkin

Reputation: 159

How to create an initial git repository from multiple versions of the 'same' codebase?

My problem is the following:

I have several directories, kind of 'branches' of the same project with no common root. (Not in the sense of it being ultimately absent, but in the sense that it is lost.)

I need to merge them together to create a single master branch. I know that some versions are derived from other versions, but unfortunately that doesn't mean that they are more advanced than their parents, since many developers just deleted source files they didn't need from their working copies.

How do I properly merge them?

Of course, I could create an empty repository, then add all directories as branches and try to merge them one by one. But is there any better option?

Upvotes: 1

Views: 43

Answers (1)

VonC
VonC

Reputation: 1324977

Considering:

  • the merge would not be a 3-way merge anyway (due to the lack of a proper common ancestor between two branches)
  • the merge wouldn't even be an automatic one (since developer have deleted sources they don't need, you don't want to do a simple merge, which could in turn delete those same source in the target branch)

the safest course of action is to use a third-party merge tool (WinMerge, kdiff3, BeyondCompare, ...), and carefully merge those folders into one target git repo folder. Pay attention in particular to files absent in the source and present in the target: you probably want to ignore those deletion and keep your target files.

Upvotes: 1

Related Questions