git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git subtree -P path split [rev] should check for path under rev, not in the current working directory

From
BLbook lv <thebookofunknowable@gmail.com>
Date
Jan 15, 2026, 04:42 UTC
Message-ID
<CAFePT4xDGegpEFuFemCXsH890E2WXnG3JzUZeiLi9KW8D8beOg@mail.gmail.com>
Hello Git Developers,

I encountered an issue while using the command `git subtree -P path split [rev]` to extract a subdirectory from a local branch (which was not checked out). Due to paths in that branch that cannot be handled on Windows, I was unable to check it out. However, the specific folder I intended to process did not contain any problematic paths, so I planned to split it into a separate repository for further work.

During the operation, I received an error: fatal: 'path' does not exist; use 'git subtree add'

However, I confirmed via git ls-tree that the specified revision (rev) does contain the folder in question.

After reviewing the source code, I identified that the check for the existence of path is performed against the current working directory, rather than validating whether path exists under the given revision (rev). As a workaround, I temporarily created the corresponding folder locally, which allowed the split operation to proceed successfully.

While this workaround resolved my immediate issue, I believe the current behavior is unreasonable. The error message is misleading and does not reflect the actual problem. I suggest modifying the validation logic to check for the existence of path under the specified revision (rev), rather than in the current working directory.

My environment: Git version: 2.52.0.windows.1

Thank you for your time and consideration.
Best regards
Message 1 of 1 in “git subtree -P path split [rev] should check for path under rev, not in the current working directory”
  1. book lvJan 15, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.