ern*_*ain 10
使用以下内容创建名为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)从git项目的根目录运行脚本作为命令:
./git-copy.sh git-hash-1 git-hash-2 path/to/destination/folder
Run Code Online (Sandbox Code Playgroud)它会将具有相同目录结构的所有文件复制到目标文件夹.