Git archive of repository with uncommitted changes

前端 未结 9 734
旧时难觅i
旧时难觅i 2021-02-01 18:31

How can I create an archive of the current repository including local uncommitted changes using git archive?

9条回答
  •  广开言路
    2021-02-01 19:13

    You don't have to use git stash anymore to create one artificial commit which would include your tracked change, for git archive to operate on.

    With Git 2.29 (Q4 2020), "git archive"(man) learns the "--add-file" option to include untracked files into a snapshot from a tree-ish.

    See commit df368fa, commit 2947a79, commit 200589a (19 Sep 2020) by René Scharfe (rscharfe).
    (Merged by Junio C Hamano -- gitster -- in commit f6b06b4, 05 Oct 2020)

    archive: add --add-file

    Signed-off-by: René Scharfe

    Allow users to append non-tracked files.
    This simplifies the generation of source packages with a few extra files, e.g. containing version information.
    They get the same access times and user information as tracked files.

    git archive now includes in its man page:

    --add-file=

    Add a non-tracked file to the archive.
    Can be repeated to add multiple files.
    The path of the file in the archive is built by concatenating the value for --prefix (if any) and the basename of .


    I also like the Git 2.30 alternative to tar.

提交回复
热议问题