What's the command to reset a file to a specific commit?

This question already has an answer here:

  • Reset or revert a specific file to a specific revision using Git? 28 answers
  • How to revert Git repository to a previous commit? 38 answers

  • Mind your terminology. With git "reset" refers to setting a ref (eg branch) to a new commit. You want to put a file from some commit into your working copy. Exactly this is a "checkout".

    You can checkout all files of a commit with

    git checkout commit
    

    or only part of the commit with

    git checkout commit file
    

    If you only want to "show" a file of some commit without changing your working copy you can also use

    git show commit:file
    
    链接地址: http://www.djcxy.com/p/3148.html

    上一篇: Git扭转错误

    下一篇: 将文件重置为特定提交的命令是什么?