V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
coolair
V2EX  ›  问与答

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

  •  
  •   coolair · 2022-10-14 14:46:05 +08:00 · 1305 次点击
    这是一个创建于 552 天前的主题,其中的信息可能已经有所发展或是发生改变。
    不想把 git 记录弄到服务器上去。
    8 条回复    2022-10-15 11:07:59 +08:00
    0o0O0o0O0o
        1
    0o0O0o0O0o  
       2022-10-14 14:48:19 +08:00 via iPhone
    git diff --name-only
    lambdaq
        2
    lambdaq  
       2022-10-14 14:53:04 +08:00
    diff 协议就是差量化拉代码的工具哎。。。。不要记录可以 git pull --depth=1
    ShineyWang
        3
    ShineyWang  
       2022-10-14 14:57:35 +08:00
    我之前弄过,把本地的 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
        4
    ETiV  
       2022-10-14 15:05:19 +08:00
    可以试试 cherry-pick 单独的 commit 过来
    也可以直接出 2 个 commits 的 patch ,直接打到服务器的文件上…

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

    这个命令会返回两个 commit 之间变更过文件列表,之前做过升级包方案的时候用过这个东西
    sjzar
        8
    sjzar  
       2022-10-15 11:07:59 +08:00
    git format-patch & git apply
    做个 patch 带走
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5435 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 03:31 · PVG 11:31 · LAX 20:31 · JFK 23:31
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.