I created a branch called "feature/my-third-branch" and created a hidden folder with a simple text file. If I switch to another branch and try to view this file using "git show" I get an error. If I repeat the "git show" to another hidden folder in a different branch with no slash it works fine.
(master)
$ git checkout feature/my-third-branch
Switched to a new branch 'feature/my-third-branch'
branch 'feature/my-third-branch' set up to track 'origin/feature/my-third-branch'.
(feature/my-third-branch)
$ cat .secondhiddenfolder/thirdfile.txt # show file in branch triggering error
this is my third file
(feature/my-third-branch)
$ git checkout my-first-branch
Switched to a new branch 'my-first-branch'
branch 'my-first-branch' set up to track 'origin/my-first-branch'.
(my-first-branch)
$ cat .hiddenfolder/file.txt # show file in branch that doesn't trigger error
this is the contents of file in hidden folder
(my-first-branch)
$ git checkout my-second-branch # switch to a neutral branch
Switched to a new branch 'my-second-branch'
branch 'my-second-branch' set up to track 'origin/my-second-branch'.
(my-second-branch)
$ git show my-first-branch:.hiddenfolder/file.txt # 'git show' from branch without slash works
this is the contents of file in hidden folder
(my-second-branch)
$ git show feature/my-third-branch:.secondhiddenfolder/thirdfile.txt # 'git show' from branch with slash generates error ...
fatal: ambiguous argument 'feature\my-third-branch;.secondhiddenfolder\thirdfile.txt': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
(my-second-branch)
$ git show 'feature/my-third-branch:.secondhiddenfolder/thirdfile.txt' # ... even with single qutoes ...
fatal: ambiguous argument 'feature\my-third-branch;.secondhiddenfolder\thirdfile.txt': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
(my-second-branch)
$ git show "feature/my-third-branch:.secondhiddenfolder/thirdfile.txt" # ... and double quotes.
fatal: ambiguous argument 'feature\my-third-branch;.secondhiddenfolder\thirdfile.txt': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
(my-second-branch)
$ git --version
git version 2.41.0.windows.3
What I noticed in the error output is that the colon (:) has changed to a semicolon (;). I've tried different ways of escaping but nothing seems to work.
What do I need to do to get 'git show' to work with a branch that includes a forward slash (/) in the name?
EDIT 1
Just in case anyone missed the last line of output, this is Git for Windows GitBash. No, I haven't tried CMD or PowerShell as I am hoping to stick to GitBash for ease of portability to Linux.
I forgot to mention that I tried disabling the path conversion in CygWin.
How to stop MinGW and MSYS from mangling path names given at the command line https://stackoverflow.com/a/34386471/8469997
(my-second-branch)
$ MSYS_NO_PATHCONV=1
(my-second-branch)
$ git show feature/my-third-branch:.secondhiddenfolder/thirdfile.txt
fatal: ambiguous argument 'feature\my-third-branch;.secondhiddenfolder\thirdfile.txt': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
(my-second-branch)
$ MSYS2_ARG_CONV_EXCL="*"
(my-second-branch)
$ git show feature/my-third-branch:.secondhiddenfolder/thirdfile.txt
fatal: ambiguous argument 'feature\my-third-branch;.secondhiddenfolder\thirdfile.txt': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
(my-second-branch)
$
EDIT 2
Disabling with double forward slash (//) doesn't help either (https://stackoverflow.com/a/14189687/8469997) but does give a different error:
(my-second-branch)
$ git show feature/my-third-branch://.secondhiddenfolder/thirdfile.txt # https://stackoverflow.com/a/14189687/8469997
fatal: path '//.secondhiddenfolder/thirdfile.txt' does not exist in 'feature/my-third-branch'
(my-second-branch)
$ git show 'feature/my-third-branch://.secondhiddenfolder/thirdfile.txt' # https://stackoverflow.com/a/14189687/8469997
fatal: path '//.secondhiddenfolder/thirdfile.txt' does not exist in 'feature/my-third-branch'
(my-second-branch)
$