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

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

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

21条回答
  •  清酒与你
    2020-11-22 09:08

    Working in GIT 1.7.2.2

    For example you have a remote some_remote with branches branch1, branch32

    so to checkout a specific file you call this commands:

    git checkout remote/branch path/to/file
    

    as an example it will be something like this

    git checkout some_remote/branch32 conf/en/myscript.conf
    git checkout some_remote/branch1 conf/fr/load.wav
    

    This checkout command will copy the whole file structure conf/en and conf/fr into the current directory where you call these commands (of course I assume you ran git init at some point before)

提交回复
热议问题