I ran into a [potential] problem recently when migrating an application from when repository to another.  I was only switching repo’s because my PaaS provider, as they all do, creates templated application structures for all new applications. Even though the original application’s repository is gone, its history is still valuable to me. Luckily, this can be fixed relatively easily with a little git magic!

# Go to the new repository
cd /path/to/new

# Add the original repository as a remote
git remote add original /path/to/old

# Get the original's branch and merge it into yours
git fetch original/master
git merge original/master

After the merge operation, you may find that a few of the files included in the application template have some conflicts.  You can simply resolve these by copying over the originals and committing the merge.  Your other option is to merge using the theirs strategy option by including “-Xtheirs” in your merge command:

# Use the 'theirs' strategy option during a git merge
git merge -Xtheirs original/master