是否可以使用 git archive 仅下载在提交/修订中更改的文件

Sha*_*thi 5 git bitbucket

使用 git archive commmand 是否可以仅从特定提交 ID 的存储库中下载已更改/受影响的文件?是否可以使用 Web 界面 @ bitbucket ?

Ser*_*Ten 8

列出在提交中更改的文件git diff-tree,并将它们传递到git archive.

git archive --format=zip --output=commit_files.zip <tree-ish> `git diff-tree --no-commit-id --name-only -r <tree-ish> | sed ':a;N;$!ba;s/\n/ /g'`
Run Code Online (Sandbox Code Playgroud)

  • 没想到这会起作用,但它就像魅力一样起作用!+1。只需将 `&lt;tree-ish&gt;` 替换为提交,例如 `e8d7a3d` (2认同)

小智 1

您可以创建专注于特定提交的存档文件,但它会存档整个存储库,而不仅仅是更改/受影响的文件。不过,您可能可以通过日志找出这些内容。

示例:如果您想要 bitbucket 的最新更改,它将类似于:

git archive -format=tar --remote=<PATH_TO_YOUR_REPO> HEAD
Run Code Online (Sandbox Code Playgroud)