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

后端 未结 30 2877
暖寄归人
暖寄归人 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 23:01

    This will copy the files in a range of commits (C to G) to a tar file. Note: this will only get the files commited. Not the entire repository. Slightly modified from Here

    Example Commit History

    A --> B --> C --> D --> E --> F --> G --> H --> I

    git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT C~..G | xargs tar -rf myTarFile.tar
    

    git-diff-tree Manual Page

    -r --> recurse into sub-trees

    --no-commit-id --> git diff-tree outputs a line with the commit ID when applicable. This flag suppressed the commit ID output.

    --name-only --> Show only names of changed files.

    --diff-filter=ACMRT --> Select only these files. See here for full list of files

    C..G --> Files in this range of commits

    C~ --> Include files from Commit C. Not just files since Commit C.

    | xargs tar -rf myTarFile --> outputs to tar

提交回复
热议问题