如何在git的暂存区域中下载差异 [英] How to download the diffs present in the staging area in git

查看:53
本文介绍了如何在git的暂存区域中下载差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以下载git暂存区中除git stash以外的暂存区中存在的文件的差异.我可能想要一种将差异文件下载为tar球的方法?

Is there a way to download the diffs of the files present in staging area in git other than git stash. I would probably want a way to download the diffs as a tar ball?

推荐答案

由于 git存档 仅适用于树状结构,您需要:

Since git archive works only with a treeish, you would need to:

也就是说:

git add .
git commit -m "tmp commit for export"
git archive -o patch.zip @ $(git diff --name-only @~..@)
git reset @~

注意:如果这些文件的路径名中有空格,则可能需要:

Note: if you have spaces in the pathnames of those files, you might need instead:

git diff -z --name-only @~ @ | xargs -0 git archive -o patch.zip @

这篇关于如何在git的暂存区域中下载差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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