Git: Checkout only files without repository?

前端 未结 6 1499
故里飘歌
故里飘歌 2020-12-13 04:31

i\'d like to just checkout the files without the .git files and the whole repository. It\'s because i\'d like to manage a website (php & html) with git and i\'m looking

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-13 04:43

    The git-archive manpage contains the following example:

    git archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf -)

    Create a tar archive that contains the contents of the latest commit on the current branch, and extract it in the '/var/tmp/junk' directory.

    Or you can use low level git-checkout-index, which manpage contains the following example:

    Using git checkout-index to "export an entire tree"

    The prefix ability basically makes it trivial to use 'git checkout-index' as an "export as tree" function. Just read the desired tree into the index, and do

       $ git checkout-index --prefix=git-export-dir/ -a
    

    git checkout-index will "export" the index into the specified directory.

    The final "/" is important. The exported name is literally just prefixed with the specified string.

    Or you can try to use --work-tree option to git wrapper, or GIT_WORK_TREE environment variable, e.g. by using "git --work-tree=/somwehere/else checkout -- .".

提交回复
热议问题