git subtree split exporting everything BUT the prefix

Viewed 88

I want to export a directory from a git repository into a new repository using git subtree split.

According to the examples in e.g. here

https://lostechies.com/johnteague/2014/04/04/using-git-subtrees-to-split-a-repository/

the command

git subtree split --prefix=lib -b split

splits out the directories under lib into a new branch. I can reproduce this in a newly created repo fine.

When I use the command on my repo that has a directory /firmware that I would like to split out, the command below creates a branch with everything BUT /firmware.

git subtree split --prefix=firmware -b split

Is this a bug in git subtree, or am I using git subtree the wrong way?

1 Answers

Is this a bug in git subtree, or am I using git subtree the wrong way?

Neither. It's how git subtree works. When you add a subtree it's added inside the prefix. When you split the subtree the prefix is removed and the subtree is extracted to the root.

Related