问题
In a repository A the folder sub is included as git subtree of the repository S - pointing to master branch.
I have forked repository A into F. Now I want to do one of the following in F:
- change
subto use a different branch ofS(iedevelopbranch) - or: change
subto use a different repository altogether
Is either one of these possible, and if so, how? Will there be any side effects I should know of?
And how can I make sure my subtree change won't be updated in repository A when I merge my changes (pull request)? I mean besides isolating commits.
回答1:
If you used git subtree (and not git submodule) to create the subtree, then it's just a normal dir. To switch it to another branch, just delete it and recreate the subtree from the new branch. This is:
git rm <subtree>
git commit
git subtree add --prefix=<subtree> <repository_url> <branch>
That should work without problems.
来源:https://stackoverflow.com/questions/18536279/git-subtree-possible-to-change-subtree-branch-path-in-a-forked-repository