Git的。如何使用已更改的文件创建归档文件? [英] Git. How to create archive with files, that have been changed?

查看:111
本文介绍了Git的。如何使用已更改的文件创建归档文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

保留文件结构,如 git-archive

解决方案

git archive 以文件路径作为参数,因此您可以执行以下操作:

  git diff --name-status commit1 commit2 | awk'{if($ 1!=D)print $ 2}'| xargs git archive -o output.zip HEAD 

UPDATE



如果你的文件名包含空格,那么下面的代码就可以运行:

  git diff  - 名称状态commit1 commit2 | awk'{if($ 1!=D)printf(\%s \\\\
,substr($ 0,3))}'| xargs git archive -o output.zip HEAD -

注意:包含在归档就是它在HEAD上的内容。要使用其他提交的内容,只需将该命令末尾的 HEAD 更改为您希望的内容即可。


Keeping the file structure, like git-archive

解决方案

git archive takes file paths as arguments, so you could do something like:

git diff --name-status commit1 commit2 | awk '{ if ($1 != "D") print $2 }' | xargs git archive -o output.zip HEAD

UPDATE

The following will work if your file names include spaces:

git diff --name-status commit1 commit2 | awk '{ if ($1 != "D") printf("\"%s\"\n", substr($0,3)) }' | xargs git archive -o output.zip HEAD --

Note: the content of the files included in the archive is what it is at HEAD. To use content from some other commit, just change HEAD at the end of this command to whatever you want it to be.

这篇关于Git的。如何使用已更改的文件创建归档文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆