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

1 messages from 2026-01-15 to 2026-01-15. Participants: book lv.
Thread: https://gitlist.dev/t/64807

## book lv, 2026-01-15 04:42

Subject: git subtree -P path split [rev] should check for path under rev, not in the current working directory
Message-ID: <CAFePT4xDGegpEFuFemCXsH890E2WXnG3JzUZeiLi9KW8D8beOg@mail.gmail.com>
URL: https://gitlist.dev/e/CAFePT4xDGegpEFuFemCXsH890E2WXnG3JzUZeiLi9KW8D8beOg%40mail.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

```
