有没有办法下载git stash以外的git中暂存区域中存在的文件的差异。我可能想要一种方法来下载差异作为焦油球吗?
答案 0 :(得分:1)
由于git archive
仅适用于树木,因此您需要:
git reset
(恢复索引)那是:
git add .
git commit -m "tmp commit for export"
git archive -o patch.zip @ $(git diff --name-only @~..@)
git reset @~
注意:如果这些文件的路径名中有空格,则可能需要:
git diff -z --name-only @~ @ | xargs -0 git archive -o patch.zip @
答案 1 :(得分:0)
假设:
git add <filename>
的
for f in $(git diff --cached --name-only); do \
p="$f.patch"; git diff --cached -- "$f" > "$p" && zip p.zip "$p" && rm "$p"; \
done
adding: file-1.c.patch (deflated 36%)
adding: file-2.c.patch (deflated 44%)
查看存档内容:
unzip -l p.zip
Archive: p.zip
Length Date Time Name
--------- ---------- ----- ----
259 2016-08-07 19:24 file-1.c.patch
347 2016-08-07 19:24 file-2.c.patch
--------- -------
606 2 files