Reputation: 1143
I am moving a lot of projects into private repositories in GitHub. A lot of these are projects that are no longer actively in use. As such, I'd rather not have a dedicated repository per each of these projects - I'd like to lump them all into one 'Deprecated Projects' repository. I would like to do this and maintain the history of each individual project.
I've tried just placing the project directories, along with their .git directories, into the main Deprecated Projects repository, but this doesn't seem to work - only the directory actually seems to get tracked/versioned in the main repository, but none of it's files.
What is the best option available to me in this situation? I have tried renaming the .git directories in the sub-directories / projects to .git-directory, and this seems as though it removes the problem - all the files in the projects get added to the main repository correctly. If this does indeed work exactly as I want, then this would be an acceptable solution - just having to rename the .git-directory folder to .git if I did want to move the project out of the 'Deprecated Repositories' repo, and start active development on it again. If anybody can confirm whether this approach is okay, or is likely to result in problems, that would be very useful.
I'm pretty new, so any information on this would be greatly appreciated!
Upvotes: 3
Views: 772
Reputation: 213777
Use subtree merging.
Subtree merging allows you keep the history of every project, and the latest commit will have each project in a separate directory. This is ideal if all the projects are inactive.
You can brows the history in gitk
as normal, and the SHA-1 hashes are preserved.
Suppose you have the master repo in master-repo
and the project to merge in project
. Here are the steps:
cd master-repo git remote add project1 ../project1 git fetch project1 git merge -s ours --no-commit project1/master git read-tree --prefix=project1 -u project1/master git commit -m "Added project 1"
In other words,
Note, by itself, this will not preserve branches from the projects other than "master". You can preserve them by putting them in other subdirectories, or you can skip the read-tree
step and just make merge commits without actually bringing in files from those branches.
Upvotes: 2