質問

I have a project which uses a few self made "modules". I want to put these modules in separate (read only) repositories. I tried to do this with the subtree split command. But I don't see my new branched repository anywhere.

I first ran this command:

git subtree split --prefix=src/Modules/Infra --branch=infra --annotate='Infra folder split' --rejoin master

Then with the Github GUI client (I'm on Windows) I synced the changes that where pending.

But I don't see any difference. Shouldn't there be a new Repository in my Github account named infra? That's what I'm trying to accomplish with this... Is there anything else I have to do to get this to work?

役に立ちましたか?

解決

Running only that command will not create a new project in Github, it will only create a separate tree of commits in which your --prefix directory is the root instead of a subdirectory.

Running that command will output a hash that is the last commit of the new split tree. That is the commit that can be pushed into a new project in Github, but you have to manually create the new project.

# First create a new empty Github project

# In your original repository add it as a remote
git remote add subtree_repo path/to/github/repo

# push the split commit hash into the new project as master
git push subtree_repo subtree_hash:master

If you no longer have the hash, check the commit that was created by the git subtree split command. Since you used --rejoin a commit was created that merged the split tree into your master branch. One of the parents of that commit is the split tree you want.

Some extra subtree documentation.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top