Do a “git export” (like “svn export”)?

后端 未结 30 2910
暖寄归人
暖寄归人 2020-11-21 22:33

I\'ve been wondering whether there is a good \"git export\" solution that creates a copy of a tree without the .git repository directory. There are at least thr

30条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-21 22:51

    I found out what option 2 means. From a repository, you can do:

    git checkout-index -a -f --prefix=/destination/path/
    

    The slash at the end of the path is important, otherwise it will result in the files being in /destination with a prefix of 'path'.

    Since in a normal situation the index contains the contents of the repository, there is nothing special to do to "read the desired tree into the index". It's already there.

    The -a flag is required to check out all files in the index (I'm not sure what it means to omit this flag in this situation, since it doesn't do what I want). The -f flag forces overwriting any existing files in the output, which this command doesn't normally do.

    This appears to be the sort of "git export" I was looking for.

提交回复
热议问题