简体   繁体   English

如何从git导出所有分支更改的文件与本地主文件相比

[英]how to export all branch changed files compared to local master from git

I am using the following to export all the changed files from my master branch: 我正在使用以下内容从我的master分支导出所有更改的文件:

git archive --output=test_v2.zip HEAD $(git diff --name-only master)

however it gives me the following error: 但是它给我以下错误:

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

what am I doing wrong? 我究竟做错了什么?

it creates test_v2.zip but it is empty. 它创建了test_v2.zip,但为空。

based on my research I think I should not use $ sign but I don't know what to use then. 根据我的研究,我认为我不应该使用$符号,但是我不知道该使用什么。 在此处输入图片说明

Your example works fine in bash . 您的示例在bash运行良好。 But you try to run it in cmd.exe . 但是您尝试在cmd.exe运行它。 The $() syntax is Bash syntax to start a subshell, execute the enclosed command and replace the construct with the output. $()语法是Bash语法,用于启动子shell,执行附带的命令并将结构替换为输出。

Either do the same in Git Bash (anyway the better choice) or use a cmd.exe specific construct instead if one exists. 在Git Bash中进行相同的操作(无论如何都是更好的选择),或者使用cmd.exe特定的构造代替(如果存在)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 GIT:如何使用 git 命令获取从主分支到自定义分支的最新更改? - GIT : How to get latest changes from master branch to the custom branch using git commands? 提取git提交中更改的所有文件 - extract all files changed in a git commit 如何重置整个Git存储库,而不只是重置“ Master”分支,以匹配Remote? - How to reset the entire Git repository, and not only the “Master” branch, to match Remote? Git:如何更新master分支,一步切换到master分支? - Git: How to update the master branch and switch to it in one step? 每当我创建一个新分支时,它都会显示存储在 master 分支中的所有文件,它应该是空的 - Whenever I create a new branch it shows all files stored in master branch that it should be empty 如何将更改从master转移到Feature分支 - How can I get changes from master into feature branch 如何显示所有已更改的文件? - How to show all the files that have been changed? Google存储库工具(主分支)无法从Windows上的本地镜像同步 - Google repo tool (master branch) fails to sync from local mirror on Windows git - 切换到本地开发,然后返回功能分支重置修改/添加文件的状态 - git - Switching to a local develop, then back to feature branch resets the status of modified/added files Git报告Windows 8上已更改的文件 - Git reports changed files on Windows 8
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM