I'm trying to view the contents of a file located in a branch named wip like so:
git show wip:local-config.php
However, I'm receiving the following error:
fatal: Path 'local-config.php' exists on disk, but not in 'wip'.
I tried correcting the path but it failed:
git show wip:./local-config.php
Rather than using another branch, I tried to reference a previous commit from the same branch like so:
git show cd14704:local-config.php
That gave this error:
fatal: Path 'local-config.php' exists on disk, but not in 'cd14704'.
Finally when I try to show the current local-config.php I get no output at all:
git show local-config.php
According to the manual this is possible: https://www.kernel.org/pub/software/scm/git/docs/git-show.html. What am I doing wrong?
It sounds like the file you're searching for does not exist in any commits within wip. git show will only display tracked objects with some history in the refspec you provide it (in this case, wip, or cd14704). To get the expected behavior you'll need a commit with that file present.
FYI, I got this same error when I was accidentally using the full path to the file:
git show rev:/path/to/repo-root/folder/my-file
But you need to use the relative path from the repo root:
git show rev:folder/my-file
I experienced exactly the same thing. The problem was that I used backslashes in my file path. So I replaced them by regular slashes and it started working just fine. Very confusing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With