git - checkout single file under bare repository

后端 未结 3 2085
不思量自难忘°
不思量自难忘° 2021-02-19 07:47

On the server I have bare repository which is origin for development process and to simplify deployment to QA environment.

So in post-receive it simply does

3条回答
  •  清酒与你
    2021-02-19 08:10

    This git show or similar git cat-file blob approaches work more-or-less fine for text files, but they are hopeless for binary files.

    Better approach which works reliably for any kind of files and even allows to checkout entire folders:

    git archive mybranch folder/file.txt --output result.tar
    

    It creates a tar archive with desired content, exactly the file that sits in the source control. Works perfectly fine with binary files.

    The only thing you need to do is to extract this tar file

    tar -xf result.tar
    

    See my blogpost for more details

提交回复
热议问题