deed02392
deed02392

Reputation: 5032

Merge two untracked folders with Git

Until now our team worked against two copies of the same project source, one for live and one for testing. In some instances sloppiness meant that the live version had fixes that weren't applied to the development copy.

I now want to merge both into a single Git repository and start doing strict/sensible version control with the project source. I know the solution is going to by highly handraulic, but:

What's the best way to merge two separate directories of source into a single Git repository, when neither represents a specific branch of the other?

Upvotes: 0

Views: 248

Answers (1)

Thomas
Thomas

Reputation: 182083

I just tried this process, and it seems to work:

git init .
cp -r /dir/one/* .
git add .
git ci -m'Commit directory one'

So now we have directory one on branch master. Do the same for two, creating a new branch that doesn't share history:

git checkout --orphan two
git rm -rf .
cp -r /dir/two/*
git add .
git ci -m'Commit directory two'

Then just merge as usual:

git checkout master
git merge two

Upvotes: 2

Related Questions