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

后端 未结 10 1386
臣服心动
臣服心动 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:18

    Get the file from a previous commit through checking-out previous commit and copying file.

    • Note which branch you are on: git branch
    • Checkout the previous commit you want: git checkout 27cf8e84bb88e24ae4b4b3df2b77aab91a3735d8
    • Copy the file you want to a temporary location
    • Checkout the branch you started from: git checkout theBranchYouNoted
    • Copy in the file you placed in a temporary location
    • Commit your change to git: git commit -m "added file ?? from previous commit"

提交回复
热议问题