git show $(git rev-list --max-count=1 --all -- ranker/knowledge/city_province_map.py)^:ranker/knowledge/city_province_map.py
This gives me the error:
fatal: bad revision '^:ranker/knowledge/city_province_map.py'
I also tried:
git show HEAD^:ranker/knowledge/city_province_map.py
But this gives a similar error:
fatal: path 'ranker/knowledgw/city_province_map.py' does not exist in 'HEAD^'
I have a file deleted a while a ago and I want to see its content and restore it to the repository. I executed the two commands at the root directory of the git project in my local machine.
How to do that?
CodePudding user response:
If the file was deleted, you need to separate the path in show for it to work.... so:
git show $( whatever you are using to get the commit )^ -- path-to-file
CodePudding user response:
I suspect you have the format.pretty
config set, which affects rev-list
. You can check this of course with git config -l | grep format.pretty
From the docs for rev-list
:
--pretty[=<format>]
--format=<format>
Pretty-print the contents of the commit logs in a given format, [...]
Note: you can specify the default pretty format in the repository configuration (see git-config(1)).
And in docs for config
:
format.pretty
The default pretty format [...]