How to sparsely checkout only one single file from a git repository?

前端 未结 21 1598
Happy的楠姐
Happy的楠姐 2020-11-22 08:14

How do I checkout just one file from a git repo?

21条回答
  •  礼貌的吻别
    2020-11-22 09:06

    If you already have a copy of the git repo, you can always checkout a version of a file using a git log to find out the hash-id (for example 3cdc61015724f9965575ba954c8cd4232c8b42e4) and then you simply type:

    git checkout hash-id path-to-file
    

    Here is an actual example:

    git checkout 3cdc61015724f9965575ba954c8cd4232c8b42e4 /var/www/css/page.css
    

提交回复
热议问题