tags:

views:

46

answers:

1

I have a repository that I created early in the learning curve of a project. As I've learned more, I've realized that this is creating problems because some of the files I want tracked aren't required in the compiled source. What I'd like to do is create a new "project" parent directory, move the existing source directory into that parent directory and the migrate the files that don't need to be compiled into that parent directory.

Is that possible with git? Will I completely destroy all of the references since I'll want to move the .git/ directory up to the parent level as well?

Thanks.

+2  A: 

One option would be to just move things around within your current repository.

For example, assuming something like:

/.git
/lib/lib.c
/lib/lib.h
/test.c
/readme.txt

You could create a new folder (src below) and move the lib folder and the test.c folder into the new one (using git mv). Then the current directory will be your "project" parent directory that you want, and all the code will be in the new folder.

/.git
/src/lib/lib.c
/src/lib/lib.h
/src/test.c
/readme.txt

An alternative would be git filter-branch, as pointed out by VonC in the comments. Using that I believe you could build a restructured repository that would not have a commit for the moves, the files would just always have existed in the new structure.

Chris Shaffer
I ended up taking this simple, stupid approach after cursing myself mightily for not considering the obvious solution. Thanks, Chris.
Rob Wilkerson