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

mjd*_*per 2 git

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

我可以只获取最后提交的文件列表是单独的文件夹吗?

ern*_*ain 10

  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";
    
    Run Code Online (Sandbox Code Playgroud)
  2. 从git项目的根目录运行脚本作为命令:

    ./git-copy.sh git-hash-1 git-hash-2 path/to/destination/folder
    
    Run Code Online (Sandbox Code Playgroud)

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