Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have created a git repository for the C implementation of a program.

I am about to add a Matlab implementation and I would like to have a single repository with two subdirectories: one for the C and one for matlab.

Of course, I would like to keep the full history too!

What should I do?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

Do it in separate steps:

  1. Create two new folders: C and Matlab.
  2. Move existing files from the current location into the C folder.
  3. Start adding new files in the Matlab folder.
share|improve this answer
Thank you, I didn't thought of doing it this way! –  user36354 May 6 '10 at 20:08
@user36354 You may want to consider "4. Run git filter-branch in order to pretend the files have always been in folder C." But this is a bit advanced and not really necessary (e.g. git blame can follow the history to the original location). –  maaartinus Jun 10 '12 at 10:50


share|improve this answer
That question is different - they are discussing how to combine two git repos into one. –  Kevin Panko Jul 27 '10 at 15:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.