有人知道使用了 git 怎么快速导出两个 commit 之间修改过的文件,用于增加部署吗?

2022 年 10 月 14 日
 coolair
不想把 git 记录弄到服务器上去。
2825 次点击
所在节点    问与答
8 条回复
0o0O0o0O0o
2022 年 10 月 14 日
git diff --name-only
tf2
2022 年 10 月 14 日
diff 协议就是差量化拉代码的工具哎。。。。不要记录可以 git pull --depth=1
ShineyWang
2022 年 10 月 14 日
我之前弄过,把本地的 git 修改代码作为更新文件
#!/bin/bash
# Target directory
# https://stackoverflow.com/questions/31340933/copy-all-files-changed-in-last-commit

head0=${1:-head~0}
head1=${2:-head~1}
TARGET=${3:-publishTemp}

echo "Finding and copying files and folders to $TARGET"
for i in $(git diff --name-only $head0 $head1)
do
# First create the target directory, if it doesn't exist.
mkdir -p "$TARGET/$(dirname $i)"
# Then copy over the file.
cp "$i" "$TARGET/$i"
done
echo "Files copied to target directory";
ETiV
2022 年 10 月 14 日
可以试试 cherry-pick 单独的 commit 过来
也可以直接出 2 个 commits 的 patch ,直接打到服务器的文件上…

> 不想把 git 记录弄到服务器上去
不过你出版本不应该有更规范的方式吗?直接在生产环境修改文件,没了用 git 的优势…
Jamy
2022 年 10 月 14 日
window 系统下可以使用 TortoiseGit,
具体操作:项目根目录右键 - 日志 - 根据日志按需选择(ctrl 可多选) -- 选中有变化的文件--右键导出.
sawyera
2022 年 10 月 14 日
关键词:cherry-pick
815979670
2022 年 10 月 14 日
git diff {start_commit} {end_commit} --stat

这个命令会返回两个 commit 之间变更过文件列表,之前做过升级包方案的时候用过这个东西
sjzar
2022 年 10 月 15 日
git format-patch & git apply
做个 patch 带走

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://v2ex.ih06.com/t/886928

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX