18

I've been using git subtree split to divide up one huge repository, imported to Git from another VCS, into smaller repositories.

$ git subtree split -P ./path/to/folder/ -b folder-only

This has been working and I've moved a couple of folders out into new repositories but attempts on their siblings, after running through all the available commits, have no branch created.

The final message is

"No new revisions were found"

I don't know if this is important or not but running with --debug gives messages like the following

Processing commit: ca9d25944cf34bbe7aa356248a166ac1fb813f2a
parents: fc0e5a621ab871b8a11071eec321f4b40b8dcce0
newparents:
tree is:

Why has git subtree split failed and what can I do about it?

Boggin
  • 3,251
  • 3
  • 33
  • 48

5 Answers5

19

I had the same symptoms when my --prefix was pointing to a directory that was not known to git. In my case I had a too aggressive .gitignore configuration.

So, to clarify my suggestions.

Make sure your:

  1. --prefix folder is known to git. If needed add and commit it first.

  2. .gitignore file doesn't rule out your desired directory.

I hope this helps, or at least gives you a hint in the right direction.

dbm
  • 10,376
  • 6
  • 44
  • 56
9

At least on my Windows 10 environment, the directory you specify with the -P (--prefix) parameter in git subtree split is case sensitive. I was having the same problem as the OP until I tried the same command making sure to get the directory casing correct.

So if you're trying to split the Utility folder from c:\repo\Utility, you have to do git subtree split -P Utility ..., not git subtree split -P utility ...

Alex Dresko
  • 5,179
  • 3
  • 37
  • 57
0

In my case, when I tried to connect a subfolder in one repo as a subtree folder in other repo, the problem was related that I just confused path prefixes. Namely, I tried to use the targer repo path prefix where I should have used the source path prefix and vice versa.

When I set path prefixes correctly, everything started to work correctly.

More details. In a scenario like in this answer, part 3. git subtree. Merging the four files from contrib/completion/ of https://github.com/git/git.git into third_party/git_completion/ of the local repository. In code fragment:

# Do this the first time:
$ git remote add -f -t master --no-tags gitgit https://github.com/git/git.git
$ git checkout gitgit/master
$ git subtree split -P contrib/completion -b temporary-split-branch
$ git checkout master
$ git subtree add --squash -P third_party/git-completion temporary-split-branch
$ git branch -D temporary-split-branch

accidentally, I just wrote contrib/completion in place of third_party/git-completion which was incorrect and lead to this error. Placing prefixes to correct lines made it working like a charm.

moudrick
  • 2,148
  • 1
  • 22
  • 34
0

Git subtree is apparently case sensitive in this way as well, this is on Windows 10 using Git 2.34.1:

I changed a single character in the folder name from lower case to upper case a while ago. Git subtree split resulted in the same message: "No new revisions were found".

Temporarily changing back the case while subtree splitting solved it for me.

0

As a newbie I expected that after using git subtree split, I would be able to see the new branch online. However the branch is created locally. In order to see all local branches use

git branch

Also see related question

Push changes from git subtree to a branch for a pull request

Stefan
  • 10,010
  • 7
  • 61
  • 117