- #!/bin/bash
- # 从命令行参数获取分支名和正则表达式
- dev_branch=$1
- test_branch=$2
- grep_pattern=$3
- # 使用git diff命令查找test分支相对于dev分支修改的文件名,然后使用grep过滤文件名
- files=$(git diff --name-only ${dev_branch}..${test_branch} | grep -E ${grep_pattern})
- echo "${files}"
- # 使用xargs命令将文件名传递给git checkout命令,从test分支复制文件到dev分支
- #echo "${files}" | xargs git checkout ${test_branch} --
|