How to retrieve a single file from a specific revision in Git?

后端 未结 10 1262
臣服心动
臣服心动 2020-11-22 15:50

I have a Git repository and I\'d like to see how some files looked a few months ago. I found the revision at that date; it\'s 27cf8e84bb88e24ae4b4b3df2b77aab91a3735d8<

10条回答
  •  隐瞒了意图╮
    2020-11-22 16:03

    If you wish to replace/overwrite the content of a file in your current branch with the content of the file from a previous commit or a different branch, you can do so with these commands:

    git checkout 08618129e66127921fbfcbc205a06153c92622fe path/to/file.txt
    

    or

    git checkout mybranchname path/to/file.txt
    

    You will then have to commit those changes in order for them to be effective in the current branch.

提交回复
热议问题