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