gpt4 book ai didi

git - 复制上次提交中更改的所有文件

转载 作者:太空狗 更新时间:2023-10-29 14:26:00 26 4
gpt4 key购买 nike

如何导出在上次提交中更改的所有文件?

我能否只获取最后提交的文件列表是单独的文件夹?

最佳答案

  1. 创建一个名为 git-copy.sh 的文件,内容如下:

    #!/bin/bash
    # Target directory
    TARGET=$3
    echo "Finding and copying files and folders to $TARGET"
    for i in $(git diff --name-only $1 $2)
    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";
  2. 从 git 项目的根目录将脚本作为命令运行:

    ./git-copy.sh git-hash-1 git-hash-2 path/to/destination/folder

它将所有具有相同目录结构的文件复制到目标文件夹。

关于git - 复制上次提交中更改的所有文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31340933/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com