Reputation: 135
I have this folder layout:
workspace_folder (git repository)
* project1
* project2
* project3
* ...
workspace_folder
is a git repository, hence the project folders are already version controlled. There have been quite a lot of modifications inside.
How can I make them individual git repositories, while keeping their history?
Upvotes: 2
Views: 165
Reputation: 2200
I think you are looking for repo.
Repo is open source tool built on top of git by Google team.
Repo helps us manage the many Git repositories, does the uploads to our revision control system, and automates parts of the Android development workflow. Repo is not meant to replace Git, only to make it easier to work with Git in the context of Android. The repo command is an executable Python script that you can put anywhere in your path.
Though google designed it for their android development workflow, it is generic and servers the similar purpose needs.
Upvotes: 1
Reputation: 2726
This might sound crazy and most probably there is a better solution.
Try getting all the commits that touched one of your subprojects first
git log --pretty=format:%H -- projectA/ > <all-the-commits>
This should write all commit hashes doing changes to this folder into the file all-the-commits
.
Then create a new orphan branch (meaning that it does not have any parent commits)
git checkout --orphan <new-branch-name>
Then cherry-pick all those commits you obtained onto this new branch
cat <all-the-commits> | xargs -n 1 git cherry-pick
Check and correct the current working directory
Last but not least create a new repo and push this single branch to the other repository
git push <new-repo> <new-branch-name>
The end result should be, that in the new repository you have only files from you subproject together with all commits that changes files in this folder (and only those commits).
I had no chance to test these steps, if this sounds like a viable solution I will check and elaborate more if needed.
Upvotes: 1
Reputation: 4035
You can use git submodules and organize the repository like a "super project":
|- superproject
|- project1 (git archive) [a]
|- project2 [b]
|- project3 [c]
|- ...
The workflow git submodules may sound a bit tricky but it lets you to track changes in 2 levels (on superproject and on every submodule):
git commit
your change in submodulegit commit
your change in superprojectgit submodule update
to push change to the individual repositories that predate the superproject.You can find more about submodules on the Pro Git book https://git-scm.com/book/en/v2/Git-Tools-Submodules.
Upvotes: 1