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

后端 未结 30 3400
暖寄归人
暖寄归人 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条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-21 22:44

    I needed this for a deploy script and I couldn't use any of the above mentioned approaches. Instead I figured out a different solution:

    #!/bin/sh
    [ $# -eq 2 ] || echo "USAGE $0 REPOSITORY DESTINATION" && exit 1
    REPOSITORY=$1
    DESTINATION=$2
    TMPNAME="/tmp/$(basename $REPOSITORY).$$"
    git clone $REPOSITORY $TMPNAME
    rm -rf $TMPNAME/.git
    mkdir -p $DESTINATION
    cp -r $TMPNAME/* $DESTINATION
    rm -rf $TMPNAME
    

提交回复
热议问题