-
Notifications
You must be signed in to change notification settings - Fork 280
Q: How do I create a subrepo from a folder in old/existing work, for use in other projects (i.e. split from git subtree)
A: First cd into your local copy of that work.
Now we create a subrepo of that work, then create a branch for that subrepo:
$ git subrepo init <subdir>
$ git subrepo branch <subdir>
$ git branch
* master
subrepo/<subdir> <--This is the branch containing <subdir> and all its history
That branch can be pushed/pulled wherever you need.
Instead of putting <subdir>
into its own branch as shown above, you may put the <subdir>
into a remote repo/branch:
$ git subrepo init <subdir> [-r <remote>] [-b <branch>]
$ git subrepo push <subdir>
Do whichever makes the most sense for your <subdir>
.
To push changes you've made back to that old project, you may either use git push
, git subrepo push
, git subrepo pull
depending on the context.
A: If you want to switch tracking branch on one of your subrepos, say go to another tag use:
git subrepo clone --force -b <new_branch> <subrepo>
This will re clone your subrepo and make it track another branch. Note that if you do this changes that you haven't pushed to the subrepo will only be left in the main repo.