简体   繁体   中英

Why can't I see a deleted file from a git repository?

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?

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.prettygit 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 [...]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM