如何从 git 导出与本地主文件相比的所有分支更改文件
how to export all branch changed files compared to local master from git
我正在使用以下方法从我的主分支导出所有更改的文件:
git archive --output=test_v2.zip HEAD $(git diff --name-only master)
但是它给了我以下错误:
error: unknown option `name-only'
usage: git archive [<options>] <tree-ish> [<path>...]
or: git archive --list
or: git archive --remote <repo> [--exec <cmd>] [<options>] <tree-ish> [<path>...]
or: git archive --remote <repo> [--exec <cmd>] --list
--format <fmt> archive format
--prefix <prefix> prepend prefix to each pathname in the archive
-o, --output <file> write the archive to this file
--worktree-attributes
read .gitattributes in working directory
-v, --verbose report archived files on stderr
-0 store only
-1 compress faster
-9 compress better
-l, --list list supported archive formats
--remote <repo> retrieve the archive from remote repository <repo>
--exec <command> path to the remote git-upload-archive command
我做错了什么?
它创建 test_v2.zip 但它是空的。
根据我的研究,我认为我不应该使用 $ 符号,但我不知道该使用什么。
您的示例在 bash
中运行良好。但是你尝试在 cmd.exe
中 运行 它。 $()
语法是 Bash 语法,用于启动子 shell,执行包含的命令并用输出替换构造。
要么在 Git Bash 中做同样的事情(总之是更好的选择),要么使用 cmd.exe
特定结构(如果存在的话)。
我正在使用以下方法从我的主分支导出所有更改的文件:
git archive --output=test_v2.zip HEAD $(git diff --name-only master)
但是它给了我以下错误:
error: unknown option `name-only'
usage: git archive [<options>] <tree-ish> [<path>...]
or: git archive --list
or: git archive --remote <repo> [--exec <cmd>] [<options>] <tree-ish> [<path>...]
or: git archive --remote <repo> [--exec <cmd>] --list
--format <fmt> archive format
--prefix <prefix> prepend prefix to each pathname in the archive
-o, --output <file> write the archive to this file
--worktree-attributes
read .gitattributes in working directory
-v, --verbose report archived files on stderr
-0 store only
-1 compress faster
-9 compress better
-l, --list list supported archive formats
--remote <repo> retrieve the archive from remote repository <repo>
--exec <command> path to the remote git-upload-archive command
我做错了什么?
它创建 test_v2.zip 但它是空的。
根据我的研究,我认为我不应该使用 $ 符号,但我不知道该使用什么。
您的示例在 bash
中运行良好。但是你尝试在 cmd.exe
中 运行 它。 $()
语法是 Bash 语法,用于启动子 shell,执行包含的命令并用输出替换构造。
要么在 Git Bash 中做同样的事情(总之是更好的选择),要么使用 cmd.exe
特定结构(如果存在的话)。