Git: How to pull a single file from a server repository in Git?

后端 未结 8 1088
小蘑菇
小蘑菇 2021-01-29 17:57

I am working on a site with a server running Git. I am using Git for deployment (not GitHub). This was set up prior to my involvement using a hook method, and I referred to this

相关标签:
8条回答
  • 2021-01-29 18:33

    This can be the solution:

    git fetch
    
    git checkout origin/master -- FolderPathName/fileName
    

    Thanks.

    0 讨论(0)
  • 2021-01-29 18:40

    I was looking for slightly different task, but this looks like what you want:

    git archive --remote=$REPO_URL HEAD:$DIR_NAME -- $FILE_NAME |
    tar xO > /where/you/want/to/have.it
    

    I mean, if you want to fetch path/to/file.xz, you will set DIR_NAME to path/to and FILE_NAME to file.xz. So, you'll end up with something like

    git archive --remote=$REPO_URL HEAD:path/to -- file.xz |
    tar xO > /where/you/want/to/have.it
    

    And nobody keeps you from any other form of unpacking instead of tar xO of course (It was me who need a pipe here, yeah).

    0 讨论(0)
提交回复
热议问题